FindEmployee

FindEmployee - return boolean is v_temp number begin select...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 --------------STEP 1------------------ CREATE OR REPLACE PACKAGE emp_package is PROCEDURE NET_PAY (v_empno in number) FUNCTION FIND_EMP (v_empno in number) RETURN BOOLEAN END EMP_PACKAGE --------------STEP 2-------------------- PROCEDURE to calculate NET_SAL This Procedure will take empno as an input and it will show NET PAY [sal + comm] of that employee. -------------STEP 3-------------------- create or replace PROCEDURE net_sal (v_empno in number) is v_temp_sal number begin select sal + comm into v_temp_sal from emp where empno = v_empno DBMS_OUTPUT.PUT_LINE ('Net salary of ' || v_empno || ' is ' || v_temp_sal) ) END SQL> execute net_sal(7499) Net salary of 7499 is 1900 -------------STEP 4--------------------- FUNCTION FIND_EMP Function FIND_EMP FIND_EMP will confirm that the record of a particular employee exists or not before executing NET PAY procedure.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sheet1 Page 2 ---------------STEP 5-------------------- create or replace Function find_emp (v_empno in number)
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return boolean is v_temp number begin select empno into v_temp from emp where empno = v_empno return(TRUE) exception when no_data_found then return(FALSE) END /--------------------------STEP 6----------------------------CALLING FIND_EMP FUNCTION FROM NET_SAL PROCEDURE create or replace PROCEDURE net_sal ( v_empno in number) is v_temp_sal number begin if (find_emp(v_empno)) then select sal + comm into v_temp_sal from emp where empno = v_empno DBMS_OUTPUT.PUT_LINE('Net salary of ' || v_empno || ' is ' || v_temp_sal) else DBMS_OUTPUT.PUT_LINE('Record not found of Employee '||v_empno ) end if END------------------------STEP 7-----------------------------How to use both Function and Procedure Package body Sheet1 Page 3--------PACKAGE SPECIFICATION----------------create or replace package emp_package is procedure net_pay ( v_empno in number) function find_emp ( v_empno in number) return boolean end emp_package...
View Full Document

Page1 / 3

FindEmployee - return boolean is v_temp number begin select...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online