Path: dp-news.maxwell.syr.edu!spool.maxwell.syr.edu!drn.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!fr.ip.ndsoftware.net!proxad.net!infeed-2.proxad.net!news13-e.free.fr!not-for-mail
From: "Michel Cadot" <micadot{at}altern{dot}org>
Newsgroups: comp.databases.oracle.misc
References: <1131716031.431225.114570@g14g2000cwa.googlegroups.com>
Subject: Re: How to Use Cursor variable in Where Statement
Date: Fri, 11 Nov 2005 15:01:51 +0100
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
Lines: 36
Message-ID: <4374a44e$0$549$626a14ce@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 11 Nov 2005 15:01:50 MET
NNTP-Posting-Host: 82.67.171.166
X-Trace: 1131717710 news13-e.free.fr 549 82.67.171.166:2895
X-Complaints-To: abuse@proxad.net
Xref: dp-news.maxwell.syr.edu comp.databases.oracle.misc:123265


<wtistang@hotmail.com> a écrit dans le message de news: 1131716031.431225.114570@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


