There are two kind of variables
- Local Variables
- Global Variables
These variables are declared with in the block and can not be referenced from outer block.
Global Variables
These variables are declared in a outer block and can be referenced with in other blocks. Example
DECLARE
VAR_NUM1 number;
VAR_NUM2number;
BEGIN
VAR_NUM1 number := 10;
VAR_NUM2 number :=10;
DECLARE
VAR_ADD number;
BEGIN
VAR_ADD := VAR_NUM1 + VAR_NUM2 ;
END;
END;
/
Explanation
First of all we declared two global variables named " VAR_NUM1 and VAR_NUM2 ".Than we declared one more variable named " VAR_ADD " which has a Local scope.At the end we used to times " END " keyword.It means it is a nested Block now we can access the global variable after the last keyword written END but the Variable " VAR_ADD " can not be accessed after first Written keyword " END " because it is a Local Variable.
No comments:
Post a Comment