Saturday, 12 October 2019

PLSQL : Nesting blocks

Notice that I am using same variable name, however outer variable name can be accessed by using official.ln_email

begin <<official>> 
    declare
        ln_email varchar2(30):= 'abhishek.agrawal@official.com';
    begin
        --PERSONAL
        declare
            ln_email varchar2(30):= 'appsoracle.abhi@gmail.com';
        begin
            DBMS_OUTPUT.PUT_LINE('PERSONAL MAIL: '||LN_EMAIL);
            DBMS_OUTPUT.PUT_LINE('OFFICIAL MAIL: '||OFFICIAL.LN_EMAIL);
        end;
   
    end;
end official;


PERSONAL MAIL: appsoracle.abhi@gmail.com
OFFICIAL MAIL: abhishek.agrawal@official.com

No comments:

Post a Comment