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
Mixed Notation The fourth procedure call shows that you can mix the positional and named notation. In this situation, the first parameter uses the positional notation, & the s

CHECK Constraints in SQL A CHECK constraint is a table constraint defined using the key word CHECK, as already illustrated in several examples in this chapter. In particular,

Advantages of Subprograms The Subprograms give extensibility; that is, tailor the PL/SQL language to suit your requirements. For illustration, if you require a procedure which

Example of GROUP BY and COLLECT Operator Example: Using GROUP BY and COLLECT to obtain C_ER2 SELECT CourseId, CAST ( COLLECT (ROW (StudentId, Mark)) AS ROW (Studen

UPDATE Command- SQL Loosely speaking, UPDATE changes some of the column values of some existing rows of its target table. Thus, although some rows disappear from the target an

Question: (a) In the context of database security explain how the following database features help to enforce security in the database system: (i) Authorisation (ii) Access

%ISOPEN The Oracle closes the SQL cursor automatically after executing its related SQL statement. As a result, the %ISOPEN forever yields FALSE.

Relational Operators The relational operators permit you to compare randomly complex expressions. The list below provides the meaning of each operator:

Using Invoker Rights: By default, the stored procedure executes with the privileges of its definer, not its invoker. These procedures are bound to the schema in which they inh

Overloading: Similar to packaged subprograms, methods of the same type can be overloaded. That is, you can use similar name for various methods if their formal parameters diff