Ticker

6/recent/ticker-posts

What is PL/SQL Block Structure ?

In this PL/SQL Tutorial, We will explore about the block structure in Oracle PL/SQL.

What is PL/SQL Block Structure in Oracle

As we known that PL/SQL is a Block Structure Language because in the PL/SQL , we can write multiples block of code or we can arrange multiple code into different groups of element.

Before the start let's understand about the block, In the PL/SQL, Block is piece of code or some unit of code. 

Blocks are divided into two different category.

  1. Anonymous Block
  2. Named Block

Anonymous Block:- 

  1. Which block is not  given any name is called Anonymous Block
  2. Anonymous block has been defined into three part declaration,execution and exception handling section.
  3. Execution Section is necessary where declaration and exception handling section is optional. 
  4. It is not save as a database object.

DECLARE
(declaration section) ---OPTIONAL---
BEGIN
(execution section)---MANDATORY---
EXCEPTION
(exception handling)--OPTIONAL--
END;

We will discuss in  the details about the Anonymous block in our next PL/SQL Tutorial.

Named Block:- 

  1. Which block is given any name is called Named Block. It is different from the anonymous block. 
  2. In the Named Block, Header Section is added instead of declare keyword. 
  3. Header Section define the which types of Named Block we are creating. Procedure and Function are the  example of Named Block.
  4. Named Block is save as a database object.
  5. Named block is also example of reusability. Named block create once and runs multiple times.

HEADER-------MANDORARY---
IS/AS
(DECLARATION SECTION) ---OPTIONAL---
BEGIN
(EXECUTION SECTION)---MANDORARY---
EXCEPTION
(EXCEPTION HANDLING)OPTIONAL
END;
  

We will discuss in  the details about the Named block in our next PL/SQL Tutorial.

That's all for today, Maybe this What is PL/SQL block structure in Oracle blog post will helps you. If you like this post then share your valuable comment or view.

Post a Comment

0 Comments