Ticker

6/recent/ticker-posts

PL/SQL Block Identifier

 

PL/SQL Block Identifier

The name of any Oracle object (variable, constant, record, cursor etc.) is known as an identifier. The following laws have to be followed while working with identifiers:

1) An identifier cannot be declared twice in the same block.

2) The same identifier can be declared in two different blocks.

If one follows the second law, the two identifiers are unique and any change in one does not affect the other. An identifier can be declared in a sub-block of another sub-block in which case it is local to that sub-block alone.

To execute a PL/SQL program, one must follow the program text itself by:

1) A line with a single dot (".") and then

2) A line with run

For example,

DECLARE

account number(5);

credit_limit number(9,2),

BEGIN

DECLARE,

account char(20);

newbalance number(9,2),

BEGIN

The identifiers available to this block are

account-char(20), credit_limit, new balance

END;

DECLARE

Old_balance number(9,2);

BEGIN

/*The identifiers available to this block are account number(5), credit_limit, old_balance */

 END;

/*The identifiers available here are account nu n iber(5), credit limit*/

END: