dbTalk Databases Forums  

PL/SQL problem with Updates that specify varchar

comp.databases.oracle comp.databases.oracle


Discuss PL/SQL problem with Updates that specify varchar in the comp.databases.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Beelzehubub
 
Posts: n/a

Default PL/SQL problem with Updates that specify varchar - 08-05-2004 , 02:02 PM






Hi,
I'm having a bit of trouble with an update performed by a PL/SQL
routine that is updating more rows than it should be. Here's some of
the code:

Note that ZENT.APPID is NUMBER and ZENT.UCLS is VARCHAR(12)

OPEN APPAccessCursor;
LOOP
FETCH APPAccessCursor INTO appid,ucls;
EXIT WHEN APPAccessCursor%NOTFOUND;

UPDATE ZENT SET "ZENT"."ACCLEVEL"='N' WHERE "ZENT"."UCLS"=ucls AND
"ZENT"."APPKEY"=appid;

END LOOP;
CLOSE APPAccessCursor;

appid and ucls are populated successfully by the fetch but when the
update is performed, all rows matching appid are updated and the value
of ucls is essentially ignored. I've tried =, like, and in for the
ucls portion of the update statement and they all produce the same
result. What am I doing wrong?

Reply With Quote
  #2  
Old   
Mark D Powell
 
Posts: n/a

Default Re: PL/SQL problem with Updates that specify varchar - 08-06-2004 , 03:26 PM






pat.kelly (AT) sanchez (DOT) com (Beelzehubub) wrote in message news:<df698d61.0408051102.905f683 (AT) posting (DOT) google.com>...
Quote:
Hi,
I'm having a bit of trouble with an update performed by a PL/SQL
routine that is updating more rows than it should be. Here's some of
the code:

Note that ZENT.APPID is NUMBER and ZENT.UCLS is VARCHAR(12)

OPEN APPAccessCursor;
LOOP
FETCH APPAccessCursor INTO appid,ucls;
EXIT WHEN APPAccessCursor%NOTFOUND;

UPDATE ZENT SET "ZENT"."ACCLEVEL"='N' WHERE "ZENT"."UCLS"=ucls AND
"ZENT"."APPKEY"=appid;

END LOOP;
CLOSE APPAccessCursor;

appid and ucls are populated successfully by the fetch but when the
update is performed, all rows matching appid are updated and the value
of ucls is essentially ignored. I've tried =, like, and in for the
ucls portion of the update statement and they all produce the same
result. What am I doing wrong?
By any chance does the table zent has a column named ucls. If so you
are comparing the column to itself, which always matches. In this
case rename the plsql variable to v_ucls.

That is all I can think of with the code segment provided.
HTH -- Mark D Powell --


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.