| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL help needed
James Garrison wrote:
> In my declare section I've defined a cursor. If I cut and paste the
> select statement into SQLPLUS it returns the correct number of rows.
> When I run my script opening the cursor with a FOR..IN..LOOP it
> returns every row in the table. I'm trying to use
> DBMS_OUTPUT.PUT_LINE statements to diagnose the error but am unable to
> get it to work correctly. Here's an example:
>
>
Yee gads, how did you ever come up with this code?
If you want to update specific rows, do it like this:
Declare
CURSOR some_policies IS
SELECT p.policy_number,
p.policy_date_time
p.rowid
FROM policy p,
register_cur rc
BEGIN
FOR I IN some_policies LOOP
UPDATE policy
SET non_renewal_reason = 'I'
WHERE rowid = i.rowid;
COMMIT;
DBMS_OUTPUT.PUT_LINE (SQL%ROWCOUNT || ' policies.');
DBMS_OUTPUT.PUT_LINE ('Policy number ' || v_policy_no || ' .');
END LOOP;
![]() |
![]() |