Saturday, 21 October 2017

Blocks In PL/SQL

A PL/SQL program are logical blocks and it can nested with one another.
The basic part of PL/SQL block are
  • Declarative Part
  • Executable Part
  • Exception Handling Part

Type Of PL/SQL Block:
  1. Anonymous Block
  2. Named Block
  3. Sub Program Block
1. Anonymous Block:
  • Anonymous block known as un-named block.
  • The anonymous block cannot be called by any other block.
  • Anonymous block serve as scripts that execute PL/SQL statements .
Example Of Anonymous Block:
DECLARE
/*Declare all variable or cursor etc*/
BEGIN 
/*Write your Executable logic*/
NULL;          
/*Write your exception*/
EXCEPTIONWHEN OTHERS THEN
NULL;
END;

2. Named Block:
They have all the features as specified for the Anonymous block but the only difference is that each block can be named if necessary.

Example Of Named Block:
<<FirstNameBlock>> 
DECLARE
/*Declare all variable or cursor etc*/
BEGIN 
/*Write your Executable logic*/
NULL;          
/*Write your exception*/
EXCEPTIONWHEN OTHERS THEN
NULL;
END;

3. Sub Program Block:
  • Sub Program Blocks declare as procedure or function.
  • It also called as Named block.
  • The Sub Program block can be called by any other block.
  • Sub Program Block helps developer to reuse the code(Code Reusability ).
Example Of  Sub Program Block:

CREATE OR REPLACE PROCEDURE PROGRAM_BLOCK_EXAMPLE
AS
/*Declare all variable or cursor etc*/
BEGIN 
/*Write your Executable logic*/
NULL;          
/*Write your exception*/
EXCEPTIONWHEN OTHERS THEN
NULL;
END;




1 comment:

  1. Thanks and I have a dandy present: Whole House Renovation Cost home addition contractors near me

    ReplyDelete