Block structure in pl/sql, PL-SQL Programming

Block Structure

The PL/SQL is a block-structured language. That is, the fundamental units (procedures, anonymous blocks, and functions) that make up a PL/SQL program are logical blocks that can contain any number of nested sub-blocks. Usually, each logical block corresponds to a problem or sub problem to be solved. Hence, PL/SQL supports the divide-and-conquer approach to problem solving known as the stepwise refinement.

A block or sub-block, lets you group logically related to declarations and statements. That way, you can place the declarations close to where they are used. These declarations are local to the block and cease to be present when the block completes.

As the figure shows, a PL/SQL block has three sections: a declarative section, an executable section, and an exception-handling section. (In PL/SQL, a warning or error condition is termed as an exception.) Only the executable section is needed.

The order of the section is logical. First comes the declarative section, in which items can be declared. Once the items are declared, it can be manipulated in the executable section. The Exceptions raised during an execution can be dealt within the exception-handling section.

 

106_block structure.png

Figure: Block Structure

You can nest sub-blocks in the executable and exception-handling sections of a PL/SQL block or subprogram but not in the declarative part. You can also define local subprograms in the declarative section of any block. Though, you can call local subprograms only from the block in which they are defined.

Posted Date: 10/2/2012 1:12:27 AM | Location : United States







Related Discussions:- Block structure in pl/sql, Assignment Help, Ask Question on Block structure in pl/sql, Get Answer, Expert's Help, Block structure in pl/sql Discussions

Write discussion on Block structure in pl/sql
Your posts are moderated
Related Questions
Data Types and Representations This explains the concept possible representation, abbreviated possrep, and explains how these can be used in conjunction with constraints to de

Using Pragma RESTRICT_REFERENCES: The function called from the SQL statements should obey certain rules meant to control the side effects. To check for violation of the rules,

Entering and Exiting If you enter the executable part of an autonomous routine, the major transaction suspends. When you exit the routine, the major transaction resumes. To ex

Closing a Cursor The CLOSE statements disable the cursor, and the result set becomes undefined. An illustration of the CLOSE statement as shown: CLOSE c1;

Blocks: The fundamental program unit in the PL/SQL is the block. The PL/SQL block is defined by the keywords BEGIN, DECLARE, EXCEPTION, and END. These keywords partition the b

Parameter and Keyword Description: type_name: This identifies a user-defined type specifier that is used in the subsequent declarations of the objects. AUTHID Clause:

Components of an Object Type: An object type encapsulates the operations and data. Therefore, you can declare the methods and attributes in an object type specification, but no

Majority of Differences among 9i, 10G, 11G :- These are some combine feature which has differences among others. Automatic Workload Repository (AWR) Drop database' s

write the program for traffic control system with 10 second, 15 secod, and 20 second delay

%FOUND Until the SQL data manipulation statement is executed, the %FOUND yields NULL. Afterward, the %FOUND yields TRUE, when an INSERT, UPDATE, or DELETE statement affected o