Oracle Package Exercises

Source: Internet
Author: User

1 /*2 Create a package that implements the following functions3 1: Build a process that calculates the EMP table based on the minimum wage that the user has passed in4 number of persons below the minimum wage and information on these personnel5 2: Build a function that calculates the date of the entry based on the passed-in month6 Number of employees7 */8 9 --Package SpecificationTen Create or ReplacePackage Emp_controller One  as A        --Create a REF CURSOR -Type Emplist isRefcursor returnEmp%RowType; -  the        procedureCheck_sal_less (v_min Number, V_count out Number, v_emplist out emplist); -         -        functionCount_same_year_emp (v_year Number)return  Number; -         + End; -  + --Package Body A Create or ReplacePackage Body Emp_controller at  as -        --implementation Process -        procedureCheck_sal_less (v_min Number, V_count out Number, v_emplist out emplist) -         as -        begin -            --calculate the number of people below the minimum wage in the table, based on the minimum wage passed in in            Select Count(*) intoV_count frommyemp -            whereSal<v_min; to             +            --store people with wages below the minimum wage in a cursor -            --Open Cursor the            OpenV_emplist for Select *  frommyemp *            whereSal<v_min; $        End;Panax Notoginseng         -        --implementation Functions the        functionCount_same_year_emp (v_year Number)return  Number +         as AV_number Number; the        begin +            --Count the number of employees entering the year based on the year passed in -            Select Count(*) intoV_number frommyemp $            whereTo_char (HireDate,'yyyy')=v_year; $             -            returnV_number; -        End; the End; - Wuyi  the --Package Program Testing - Declare WuV_count Number; - v_emp emp_controller.emplist; AboutV_e myemp%RowType; $ begin -     --calculate the number of people below the minimum wage in the table, based on the minimum wage passed in -Emp_controller.check_sal_less ( -, v_count,v_emp); -Dbms_output.put_line ('the number of people below the minimum wage of 2000 is:'||V_count||', respectively, are:'); A Loop +       FetchV_emp intov_e; the       Exit  whenV_emp%NotFound; -Dbms_output.put_line ('Name:'||V_e.ename||', Salary:'||v_e.sal); $Dbms_output.put_line ('---------------------------------------'); the     EndLoop; the End; the  the --Package Test - Declare inV_number Number; the begin the     --output test, call function directly, output return value AboutDbms_output.put_line (Emp_controller.count_same_year_emp ('1981')); the End;

Oracle Package Exercises

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.