Named Blocks:
----------------
<<FirstBlock>>
DECLARE
A VARCHAR2(20):='Hello Guys';
B REAL:=500;
BEGIN
DBMS_OUTPUT.PUT_LINE('THE VALUE OF OUTER STRING A:= '||A);
DBMS_OUTPUT.PUT_LINE('THE VALUE OF OUTER REAL B:= '||B);
DECLARE
A INTEGER:=400;
B REAL:=2000;
BEGIN
DBMS_OUTPUT.PUT_LINE('THE VALUE OF INNER INTEGER A:= '||A);
DBMS_OUTPUT.PUT_LINE('THE VALUE OF INNER REAL A:= '||B);
DBMS_OUTPUT.PUT_LINE('WE R GETTING THE VALUE OF OUTER STRING A FROM INNER BLOCK:= '||FirstBlock.A);
END;
END;
/
Nested Blocks & Variable Scope:
--------------------------------------------
Ex: 1:-
DECLARE
V_N1 NUMBER:=&N1;
V_N2 NUMBER:=&N2;
V_RES NUMBER:=0;
BEGIN
DBMS_OUTPUT.PUT_LINE('FIRST NO:= '||V_N1);
DBMS_OUTPUT.PUT_LINE('SECOND NO:= '||V_N2);
DBMS_OUTPUT.PUT_LINE('SUM:= '||TO_CHAR(V_N1+V_N2,99999.99));
DBMS_OUTPUT.PUT_LINE(V_RES);
DECLARE
V_SUM NUMBER:=V_N1+V_N2;
--V_RES:=V_SUM;
V_RES NUMBER:=V_SUM;
BEGIN
DBMS_OUTPUT.PUT_LINE(V_RES);
END;
DBMS_OUTPUT.PUT_LINE(V_RES);
END;
/
Ex: 2:-
DECLARE
A VARCHAR2(20):='Hello Guys';
B REAL:=0;
BEGIN
DBMS_OUTPUT.PUT_LINE('THE VALUE OF OUTER STRING A:= '||A);
DBMS_OUTPUT.PUT_LINE('THE VALUE OF OUTER REAL B:= '||B);
DECLARE
A INTEGER:=405;
B REAL:=2000;
BEGIN
DBMS_OUTPUT.PUT_LINE('THE VALUE OF INNER INTEGER A:= '||A);
DBMS_OUTPUT.PUT_LINE('THE VALUE OF INNER REAL A:= '||B);
END;
DECLARE
D REAL:=300;
B VARCHAR2(20):='HELLO GILS';
BEGIN
DBMS_OUTPUT.PUT_LINE('THE VALUE OF INNER REAL D:= '||D);
DBMS_OUTPUT.PUT_LINE('THE VALUE OF LAST STRING B:= '||B);
END;
DBMS_OUTPUT.PUT_LINE('THE VALUE OF OUTER STRING A:= '||A);
DBMS_OUTPUT.PUT_LINE('THE VALUE OF OUTER REAL B:= '||B);
END;
/
Ur's
AmarAlam
0 comments:
Post a Comment