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!

Cursor For Loop and WHILE LOOP

vijzJan 22 2009 — edited Jan 22 2009
Hi Gurus,

I am having table like this:

TEST
NO      PK
VALUE
And I wrote a test cursor procedure for retrieving values as:
CREATE OR REPLACE
PROCEDURE test_proc_cursor
  (
    p_no OUT test.no%TYPE,
    p_value OUT test.value%TYPE)
AS
  CURSOR proc_cursor
  IS
     SELECT no,value INTO p_no, p_value FROM test;
BEGIN
  OPEN proc_cursor;
  LOOP
    FETCH proc_cursor INTO p_no, p_value;
    EXIT
  WHEN proc_cursor%NOTFOUND;
    dbms_output.put_line(p_no||'       '|| p_value);
  END LOOP;
  CLOSE proc_cursor;
END test_proc_cursor;
But, My question is , I used basic LOOP in the cursor. Can any one write the same cursor logic with WHILE LOOP and FOR LOOP's please

Thanks

Edited by: user10679113 on Jan 22, 2009 7:53 AM

Edited by: user10679113 on Jan 22, 2009 7:54 AM

Edited by: user10679113 on Jan 22, 2009 7:55 AM
This post has been answered by 170207 on Jan 22 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 19 2009
Added on Jan 22 2009
10 comments
1,123 views