home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.oracle      Overblown overpriced overengineered SHIT      2,288 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 749 of 2,288   
   Jeremy Moncho to All   
   Cursor, Fetch, and while...   
   04 Dec 03 20:01:01   
   
   From: jeremy.moncho@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;   
      
   /   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca