| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to Use Cursor variable in Where Statement
<wtistang_at_hotmail.com> a écrit dans le message de news: 1131716031.431225.114570_at_g14g2000cwa.googlegroups.com...
|I try to update the O_VALUE field in my ORDERS table using cursor
| variables, here is what I did:
|
| c_ID VARCHAR2(10);
| c_Value NUMBER(3);
| Cursor c1 IS SELECT PO_ID, PO_VALUE
| FROM PRODUCT;
| BEGIN
| OPEN c1;
| LOOP
| FETCH c1 INTO c_ID, c_Value;
| EXIT WHEN c1%NOTFOUND;
| UPDATE ORDERS SET O_VALUE= c_Value
| WHERE O_ID = c_ID;
| END LOOP;
| CLOSE c1;
|
| The ORDERS table will be updated, but I get wrong values in the O_VALUE
| field. It seems like the Where statement is not working. Did I do
| something wrong here?
| Thank you for your help.
|
|
| Mike
|
Wrong key (PRODUCT.PO_ID<=>ORDERS.O_ID)? Wrong way to do that unless it is just a PL/SQL basic exercise on cursor and even then you should have a look at BULK operations.
Regards
Michel Cadot
Received on Fri Nov 11 2005 - 08:01:51 CST
![]() |
![]() |