| 0 comments ]

SCOPE AND VISIBILITY DIAGRAM:


     Sql>    DECLARE
                    x BINARY_INTEGER;
             BEGIN
                    .......
                    ..........
                    DELARE
                          y NUMBER;
                    BEGIN
                          .....
                          ..........
                                    End of 'y';
                    END;
             END;

NESTED BLOCKS AND VARIABLE SCOPE:

a) The variable 'y' can reference the variable named 'x'.
b) The variable 'x' cannot reference variable 'y'.
c) If the variable named y in the nested block is given the same name as the variable name x in the outer block its value is valid only for the duration of the nested block.

        
       Sql> DECLARE
                   X REAL:=205;
            BEGIN
                   DBMS_OUTPUT.PUTLINE('The Value of Outer X:='||x);
                        DECLARE
                              X REAL:=405;
                        BEGIN
                              DBMS_OUTPUT.PUTLINE('The Value of Inner X:='||x);
                        END;
                   DBMS_OUTPUT.PUTLINE('The Value of Outer X:='||x);
            END;
      Sql>  DECLARE
                   A VARCHAR2(30):='Hello Guys';
                   B REAL:=0;
            BEGIN
                  DBMS_OUTPUT.PUTLINE('The Value of Outer String A is available Here:='||A);  
                  DBMS_OUTPUT.PUTLINE('The Value of Outer Real B is available Here:='||B);

                  DECLARE
                        A INTEGER :=2000;
                        B REAL:=400;
                  BEGIN
                      DBMS_OUTPUT.PUTLINE('The Value of Inner Integer A is available Here:='||A);
                      DBMS_OUTPUT.PUTLINE('The Value of Inner Real B is available Here:='||B);
                  END;
                       DECLARE
                              D REAL:=500;
                              A VARCHAR2(30):='Hellow Gals';
                       BEGIN
                            DBMS_OUTPUT.PUTLINE('The Value of Last B is available Here:='||D);
                            DBMS_OUTPUT.PUTLINE('The Value of Last String is available Here:='||A);
                       END;
            DBMS_OUTPUT.PUTLINE('The Value of Outer String A is available:='||A);
            DBMS_OUTPUT.PUTLINE('The Value of Outer Real B is available:='||B);
         END;

0 comments

AddThis

| More
Widget By Devils Workshop