help with a loop [message #38100] |
Wed, 20 March 2002 08:57 |
Lance Pris
Messages: 40 Registered: January 2002
|
Member |
|
|
Can someone look at this at see what I am doing wrong:
The following SQL returns to records:
50
333
select SC_USER_ID as parmSecurename from CP_USER_COMMENT where SC_ID =
107793;
If I include it in the following loop the result is
50
333
333
CREATE OR REPLACE Procedure SP_USER_COMMENT_2
as
--Set the User SECURE ID
parmSecurename CP_USER_COMMENT.SC_USER_ID%TYPE;
Cursor SC_SECURENAME is select SC_USER_ID as parmSecurename from
CP_USER_COMMENT where SC_ID = 107793;
Begin
Open SC_SECURENAME;
--While SC_SECURE%rowcount < 20
Loop /* Add next three lines */
fetch SC_SECURENAME into parmSecurename;
dbms_output.put_line ('USER ID: '||parmSecurename);
exit when SC_SECURENAME%NOTFOUND;
End LOOP;
Close SC_SECURENAME;
Commit;
End;
/
PLease help
Thank you in advance
|
|
|
Re: help with a loop [message #38101 is a reply to message #38100] |
Wed, 20 March 2002 09:23 |
Rajarshi
Messages: 11 Registered: November 2001
|
Junior Member |
|
|
There is a small mistake in arranging the statements within the loop... Write the PL/SQL in the following way:
Begin
Open SC_SECURENAME;
--While SC_SECURE%rowcount < 20
Loop /* Add next three lines */
fetch SC_SECURENAME into parmSecurename;
exit when SC_SECURENAME%NOTFOUND; -- This I have taken before....
dbms_output.put_line ('USER ID: '||parmSecurename);
End LOOP;
Close SC_SECURENAME;
Commit;
End;
|
|
|