Live ORACLE

if you are Oracle Developer ,than this Blog most likely will make you happy.

About my Blog

This Blog particularized for Oracle Developers ... you will see interesting Codes for SQL , PL/SQL as well as new ideas for Developer Suite and Client Tools that will help you in your professional life ... and I hope I reach for your satisfaction.

About Me

I'm Hany Freedom , 25 years old , I live in EL-Minia City in Egypt , I'm Moderator at ArabOUG.org the best Arabic Forum for ORACLE on the Net. if you interested to know more about me .... just Click Here.

Scope of the LOOP Counter Variable

The loop counter is defined only within the loop. You cannot reference that variable name outside the loop. After the loop exits, the loop counter is undefined:


BEGIN

FOR i IN 1.. 3 LOOP -- assign the values 1,2,3 to i

dbms_output.Put_line(To_char(i));

END LOOP;



dbms_output.Put_line(To_char(i)); -- raises an error



END;

/




You do not need to declare the loop counter because it is implicitly declared as a local variable of type INTEGER. It is safest not to use the name of an existing variable, because the local declaration hides any global declaration.


DECLARE

i NUMBER := 5;

BEGIN

FOR i IN 1.. 3 LOOP -- assign the values 1,2,3 to i

dbms_output.Put_line(To_char(i));

END LOOP;



dbms_output.Put_line(To_char(i)); -- refers to original variable value (5)



END;

/



Share/Save/Bookmark

0 comments:

Post a Comment



Newer Posts Older Posts Home Page
 
http://www.dpriver.com/images/sqlpp-banner-2.png

Thanks for reading my Blog ... you Visitor Number :-