on 08-22-2013 7:19 AM
I am getting an error,when looping through a cursor.Please find the code below.
c1 for SELECT Account,"Account Description" FROM "CHEP_DEMO"."TBL_PALLET_MOVEMENT";
/********* Begin Procedure Script ************/
BEGIN
open c1;
for cur_row as c1 do
end for;
close c1;
END;
I am getting an error,whenever i am having the for loop.if i remove the for loop i donot get an error.
any help is appreciated.
regards
Kaushik
Hi Kaushik,
You don't need to OPEN and CLOSE the cursor if you are using FOR loop.
As per the documentation for cursor FOR Loop:
Opens a previously declared cursor and iterates over each row in the result set of the query bound to the cursor. For each row in the result set the statements in the body of the procedure are executed. After the last row from the cursor has been processed, the loop is exited and the cursor is closed.
Please remove the OPEN and CLOSE statement and try the procedure. It will also help if you can post your complete procedure code to check if there is an error elsewhere too.
Regards,
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kaushik,
I think that you may not use for ... loop out of begin .... end, you can use fetch c1 into xxx.
If you want to use for .. loop, you can move declare cursor to begin ... end.
Hope this can help you.
Regards,
Jerry
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kaushik,
What error you are getting ,please provide that.
screen shot ,log etc...
Best Regards,
Atul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.