PLSQL Local and Global Variable

 Local and Global Variable

Global Variable  :- Global variable are variable that are declared in outermost block and available for all inner blocks.

Local Variable :-Local variable are variables those are declared in inner block and available for only that inner block


declare
a number;
b number;            --Global variable
sum1 number;
begin
a:=&a;
b:=&b;
sum1:=a+b;
dbms_output.put_line('Sum of given numbers is :'||sum1);
declare
b number;            --Local variable
begin
dbms_output.put_line('Sum of given numbers is :'||b);
end;
dbms_output.put_line('Sum of given numbers is :'||a);
end;
/

No comments:

Post a Comment