1.

How To Define A Sub Procedure?

Answer»

A sub procedure is a named procedure defined and used inside another procedure or function. You need to define a sub procedure in the DECLARATION part of the enclosing procedure or function. Sub procedure definition starts with the PROCEDURE key WORD. Here is a sample script showing you how to define and use a sub procedure:

SQL> CREATE OR REPLACE PROCEDURE HR.DBA_WEEK AS PROCEDURE DBA_TASK (day VARCHAR2) AS BEGIN IF day = 'MONDAY' THEN DBMS_OUTPUT.PUT_LINE('Checking log files.'); ELSIF day = 'FRIDAY' THEN DBMS_OUTPUT.PUT_LINE('Rebuild indexes.'); ELSE DBMS_OUTPUT.PUT_LINE('Reading some papers.'); END IF; END; BEGIN DBA_TASK('MONDAY'); DBA_TASK('TUESDAY'); END; /

SQL> EXECUTE DBA_WEEK; Checking log files. Reading some papers.

A sub procedure is a named procedure defined and used inside another procedure or function. You need to define a sub procedure in the declaration part of the enclosing procedure or function. Sub procedure definition starts with the PROCEDURE key word. Here is a sample script showing you how to define and use a sub procedure:

SQL> EXECUTE DBA_WEEK; Checking log files. Reading some papers.



Discussion

No Comment Found