Don't cursors have to run on the Primary Key? Or one has to exist on the
table in question? I can't remember exactly but I do recall something
about cursors not declaring correctly with a PK.

 

From: Action Request System discussion list(ARSList)
[mailto:[email protected]] On Behalf Of amit dw
Sent: Tuesday, February 16, 2010 3:20 PM
To: [email protected]
Subject: SQL help needed

 

** 

Hello All,

 

Below is the problem and way I was trying to handle it 

 

C_list contains comma separated values of group Id's. this list contains
all the group id's associated to a particular login name.

 

C_list= (1,15005,800005,800003,800004,805)

 

This variable will be holding up dynamically value in numbers.

 

For group id numbers in simple sql statement we can get the result
corresponding name using the below query,

 

Select c105,c106 from t10 where c106 in (1, 101,102,104). 

 

Same query when I tried transforming in a cursor it throws up a
compilation error. The error points out to a fetch statement where we
try and fetch the data from the cursor for one particular group id.

 

Declare cursor c1 as select c105,c106 from t10 where c106 in(c_list);

Begin

Open c1;

Loop

Fetch C1 into g_num,g_name;

dbms_output.put_line(g_name);

EXIT WHEN C1%NOTFOUND;

END LOOP;

Close c1;

End;

 

Hope it explains the problem I am facing.

Any suggestions/Comments or previously implemented code will be helpful
for me.

_Platinum Sponsor: [email protected] ARSlist: "Where the Answers
Are"_ 


_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
Platinum Sponsor:[email protected] ARSlist: "Where the Answers Are"

Reply via email to