Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

INTO clause inside a FOR loop's SELECT query

Boobal GanesanAug 11 2015 — edited Aug 13 2015

Guys,

When i accidentally happen to place an INTO clause in the select query placed in the FOR loop's cursor section, it worked fine! but the variable N always had NULL value in it. I have posted the script and its output below.

Script:
DECLARE

  n NUMBER;

BEGIN

  FOR i IN

  (SELECT dummy INTO n FROM dual

  )

  LOOP

    dbms_output.put_line('n value is '||NVL(TO_CHAR(n),'Null'));

  END LOOP i;

END;

Output:

anonymous block completed

n value is Null

Is this a defect in PLSQL or is this functionality meant for something really appropriate?

Thanks,

B

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 10 2015
Added on Aug 11 2015
14 comments
5,373 views