Friday, January 23, 2009

Oracle PL/SQL Anonymous Block






Anonymous blocks form the basic PL/SQL structure. It is unnamed PL/SQL block. It is used to initiate PL/SQL processing tasks from applications.

Here's the structure of anonymous block:

[ DECLARE
... optional declaration statements ... ]

BEGIN ... Start of block (Mandatory) ...
... executable statements ...

[ EXCEPTION
... optional exception handler statements ... ]

END; ... End of block (Mandatory) ...


The square brackets indicate an optional part. DECLARE keyword is optional but it is required if you declare variables. BEGIN and END are mandatory and require at least one statement between them, either SQL, PL/SQL, or both.

Here's a very basic example of anonymous block:

BEGIN
DBMS_OUTPUT.PUT_LINE("Hello, World!");
END;

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home