Explanation Pract6 Plsql
Explanation Pract6 Plsql
Parameters type
IN
OUT
IN OUT
Ex. 1: Develop a stored procedure to delete an employee based on Employee ID. Test the procedure
with different input.
Ex 2: Develop a stored procedure to delete an employee based on employee ID and demonstrate the
same.
Code:
AS
BEGIN
END;
BEGIN
delete_emp(7934);
END;
/
CODE FOR DELETING NON EXISTENT EMP
BEGIN
Delete_emp(999);
End;
/
To DELETE a Procedure:
DROP PROCEDURE delete_emp;
Another Example:
Create a procedure to calculate and return annual salary of an employee
CREATE OR REPLACE PROCEDURE Ann_SAL (
emp_sal In Number,
Asal OUT Number)
IS
Begin
Asal:=emp_sal*12;
END;
/
EXECUTE THE PROCEDURE
Set serveroutput ON
DECLARE
emp_salary Number:=&sal;
yearly_sal number;
BEGIN
Ann_sal(emp_salary,yearly_sal);
DBMS_OUTPUT.PUT_LINE('Annual Salary is ' || yearly_sal);
END;
/