SQL tutorial | Interview questions | Oracle
Would you like to react to this message? Create an account in a few clicks or log in to continue.

What Are the Types PL/SQL Code Blocks?

Go down

What Are the Types PL/SQL Code Blocks? Empty What Are the Types PL/SQL Code Blocks?

Post by Micheal Tue Jan 19, 2010 7:44 pm

There are 3 types of PL/SQL code blocks:
Anonymous Block - A block of codes with no name. It may contain a declaration part, an
execution part, and exception handlers.
Stored Program Unit - A block of codes with a name. It is similar to an anonymous block. But it
can take parameters and return values.
Trigger - A block of code that can be defined to fire based an specific event.
How To Define an Anonymous Block?
An anonymous block must have an execution part, which is a group of other PL/SQL statements
enclosed in the BEGIN ... END statement. Here is a script on how to define a simple anonymous
block with SQL*Plus:
SQL> set serveroutput on;
SQL> begin
2 dbms_output.put_line('Hello world!');
3 end;
4 /
Hello world!
PL/SQL procedure successfully completed.
"set serveroutput on;" allows dbms_output.put_line() to work.
"/" runs the anonymous block, which print the "Hello world!" message.

Micheal
Admin

Posts : 243
Join date : 2010-01-10

http://sql-tutorial.co.cc

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum