Thursday, October 17, 2013

How to write Procedure Block Name in PL/SQL simple example

----------------------------------------
Syntax:
----------------------------------------
CREATE [OR REPLACE] PROCEDURE [PROCEDURE_NAME](ARGUMENTS {IN / OUT / INOUT} DATA-TYPE)
IS/AS
    CURSOR DECLARATION;
    VARIABLE DECLARATION;
BEGIN
    SQL & PL/SQL STATEMENTS;
EXCEPTION
    ERROR HANDLING;
END;
/

-----------------------------------------
EXAMPLE:
-----------------------------------------
CREATE OR REPLACE PROCEDURE EMPPROC
IS CURSOR EMPO IS SELECT * FROM EMP;
BEGIN
    FOR REC IN EMPO
    LOOP
        DBMS_OUTPUT.PUT_LINE(REC.EMPNO,REC.NAME,REC.SALARY);
    END LOOP;
END;
/

No comments:

Post a Comment