Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Update with multiple parameters

Status
Not open for further replies.

sp1502

Programmer
Dec 15, 2000
15
US
I am trying to run an update query which uses multiple parameters in the where clause updating multiple rows based on those parameters:

UPDATE PROD.PLM103_AXXS
SET AD_ST = 'X'
WHERE (PL_L_R, L_XD_SEQ) in
((12283952,1),(12283952,3))


But it doesn't allow me to do so in SQL(DB2) giving me the following error message:

SQL0104N An unexpected token "(" was found following "_R, L_XD_SEQ) in (". Expected tokens may include: "<values> ".


Thanks in advance!!!
 

Try concatenate:

Code:
UPDATE PROD.PLM103_AXXS
   SET AD_ST = 'X'
 WHERE (PL_L_R||'+'||L_XD_SEQ)
    IN ('12283952+1','12283952+3')
[3eyes]




----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Thanks LKBrwnDBA but it doesn't like the "||", I get this message now in DB2 v8.1:

SQL0440N No authorized routine named "||" of type "FUNCTION
 
UPDATE PROD.PLM103_AXXS
SET AD_ST = 'X'
WHERE PL_L_R = 12283952 AND L_XD_SEQ IN (1,3)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV, I actually truncated my actual query by putting in 2 values..I'll probably end up have > 50 so it may look like this:

UPDATE PROD.PLM103_AXXS
SET AD_ST = 'X'
WHERE (PL_L_R, L_XD_SEQ) in
((12283952,1),(12283952,3),(1583952,1),(12583552,7)....)


Your option would work if it was limited but unfortuately I
and doing this on a bigger scale :(
 
How about
Code:
UPDATE PROD.PLM103_AXXS
   SET AD_ST = 'X'
 WHERE CONCAT(PL_L_R,CONCAT('+',L_XD_SEQ))
    IN ('12283952+1','12283952+3')
 
Code:
WHERE PL_L_R = 12283952 AND L_XD_SEQ = 1
   OR PL_L_R = 12283952 AND L_XD_SEQ = 3
   OR PL_L_R = 1583952  AND L_XD_SEQ = 1
   OR PL_L_R = 12583552 AND L_XD_SEQ = 7
   OR ...

r937.com | rudy.ca
 
Rudy, you really mix AND & OR without parentheses ?
 
carp - I received this message when I tried "
SQL0440N No authorized routine named "CONCAT" of type "FUNCTION "

r937 - thanks, I was trying to avoid typing all the fields in repeatedly like this, but this maybe the only solution!
 
The standard ANSI SQL concatenation operator is ||
So, reread the first reply and use the DB2 concatenation operator.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
i was pretty sure db2 supports ||

until now

p.s. i don't enjoy typing either, that's why i use a text editor which can do multi-line insertions at any column position :)

r937.com | rudy.ca
 
If it is truly a problem unique to DB2, have you tried asking on the DB2 forum?
 
carp, that's probably the best suggestion

notice how CONCAT got the same error message as ||

so it's probably something to do with the way the statement is consrtucted

r937.com | rudy.ca
 
According to the SQL Validator it seems like DB2 doesn't support at least some of the following:

Result:
The following features outside Core SQL-200x (draft) are used:

F641, "Row and table constructors"
T051, "Row types"
F561, "Full value expressions"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top