Structure of PL/SQL Statements

All PL/SQL functions and procedures, including packaged procedures and anonymous blocks follow the following basic layout:

Structure:

 PROCEDURE procedure (
parameter1 datatype [DEFAULT default_value1 ], parameter2 datatype [DEFAULT default_value2 ] [,...]) IS DECLARE /* declarations */ BEGIN /* executable code */ EXCEPTION /* error handling */ END; / or for a function: FUNCTION function RETURN datatype IS DECLARE /* declarations */ BEGIN /* executable code */ [RETURN value] EXCEPTION /* error handling */ END; /

To create a procedure:

CREATE OR REPLACE PROCEDURE procedure IS
 ...
 END procedure;
 /

Or a flat file SQL script can contain simply:

   BEGIN
   /* executable code */

   EXCEPTION
   /* error handling */

   END;

This is known as an 'anonymous block'


© Copyright SS64.com 1999-2014
Some rights reserved