Stored Procedures
Stored Procedures
The syntax within the brackets [ ] indicate they are optional. By using CREATE OR REPLACE together the procedure is created if no other procedure with the same name exists or the existing procedure is replaced with the current code. The below example creates a procedure employer_details which gives the details of the employee. 1> CREATE OR REPLACE PROCEDURE employer_details 2> IS 3> CURSOR emp_cur IS 4> SELECT first_name, last_name, salary FROM emp_tbl; 5> emp_rec emp_cur%rowtype; 6> BEGIN 7> FOR emp_rec in sales_cur 8> LOOP 9> dbms_output.put_line(emp_cur.first_name || ' ' || emp_cur.last_name 10> || ' ' ||emp_cur.salary); 11> END LOOP; 12>END; 13> /
2) Within another procedure simply use the procedure name. procedure_name; NOTE: In the examples given above, we are using backward slash / at the end of the program. This indicates the oracle engine that the PL/SQL program has ended and it can begin processing the statements.