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
Cursors The Oracle uses work areas to execute the SQL statements and to store process information. A PL/SQL construct known as the cursor. Let's you assume name a work area and

Example of WRAP Operator - SQL The effect of Example can be obtained in SQL but note that one needs to write down not only the names of the columns being wrapped but also the

Parameter and Keyword Description: cursor_variable_name: This identifies a cursor variable or the parameter formerly declared within the present scope. host_cursor_va

Oracle 11 G new features associated with this release:- Enhanced ILM  - Information Lifecycle Management (ILM) has been around for the almost 10 years, but Oracle has made

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

Case Sensitivity Similar to all the identifiers, the variables, the names of constants, and parameters are not case sensitive. For illustration, PL/SQL considers the following n

Use Bulk Binds If SQL statements execute inside a loop using the collection elements as bind variables, context switching between the PL/SQL & SQL engines can slow down the ex

Effects of NULL for union - SQL The treatment of NULL in invocations of EXCEPT is as for UNION. This is different from its treatment in those of NOT IN and quantified compari

Restriction and AND - SQL Restriction is available via the WHERE operator, and so it is in SQL. However, by Example showing how a certain simple restriction can be expressed u

Important Distinctions The list of important distinctions are given below: Value versus variable Syntax versus semantics Variable versus variable reference