question

OraLearner avatar image
OraLearner asked

What are Anonymous Blocks in PL/SQL ?

What are Anonymous Blocks in PL/SQL and what are its main features ? Thank you.

oracleplsql
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
KillerDBA avatar image
KillerDBA answered

There are two kinds of program blocks in PL/SQL, anonymous program blocks and named program blocks. The anonymous ones don't have headers or names and can't be called or referred to specifically but can be used to encapsulate code and limit the scope of declarations or just to provide a block of code where one is syntactically required.

Simplest anonymous block:

begin
  null;
end;
/

It doesn't actually do anything. This example from "Oracle Database 11g PL/SQL Programming" by Michael McLaughlin, page 27.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.