Re: Cursor, Fetch, and while...

From: <mcstock>
Date: Thu, 4 Dec 2003 13:26:45 -0500
Message-ID: <PvSdnQF5efsW4VKiRVn-ig_at_comcast.com>


your WHILE loop never executes

  • mcs

"Jeremy Moncho" <jeremy.moncho_at_bluewin.ch> wrote in message news:BBF542FD.14A4%jeremy.moncho_at_bluewin.ch...
| Hi guys,
|
| I am having a comprehension problem for which I cannot seem to find an
| answer (by banging my head on my keyboard.)
|
| I have the following code which yields no results. I expect one result to
| come out of it as I am using a while loop on a cursor set to retrieve one
| single tuple.
|
| Please be nice, it is my first day seeing cursors ;-)
|
| Tia,
|
| jeremy
|
|
| CREATE TABLE people(
| id int,
| fname VARCHAR2(20),
| lname VARCHAR2(20)
| );
|
| insert into people values (0, 'lois', 'lane');
| insert into people values (1, 'clark', 'kent');
| insert into people values (2, 'jimmy', 'olsen');
|
| set serveroutput on;
|
|
| CREATE OR REPLACE PROCEDURE show(curr_id INT)
| AS
| CURSOR curr_in IS SELECT fname, lname FROM people WHERE id=curr_id;
| curr_fname VARCHAR2(20) := null;
| curr_lname VARCHAR2(20) := null;
|
| BEGIN
| OPEN curr_in;
|
| while curr_in%found loop
| FETCH curr_in INTO curr_fname, curr_lname;
| dbms_output.put_line('done');
| dbms_output.put_line(curr_fname || ' ' || curr_lname);
| end loop;
|
| CLOSE curr_in;
|
| EXCEPTION
| WHEN OTHERS THEN
| dbms_output.put_line(sqlcode || ' ' || sqlerrm);
| END;
|
| /
|
|
Received on Thu Dec 04 2003 - 19:26:45 CET

Original text of this message