View previous topic :: View next topic
|
Author |
Message |
chandu.be
New User
Joined: 17 Jul 2006 Posts: 9 Location: Bagalore
|
|
|
|
Hi,
I have the following requirement:
I have two tables A & B. Both A & B are having the same columns 'col1', 'col2' and 'col3'. ('col1', 'col2' are part of primary key).
There are some rows in B table where col3 is not matching with A table.
So i need to write an SQL to update all the col4 values to match A table.
I tried the following query:
UPDATE B
SET COL3 = (SELECT COL3
FROM A WHERE A.COL1 = B.COL1 AND A.COL2 = B.COL2
AND A.COL3 <> B.COL3);
But it is giving me SQLCODE -4700.
Please help me.
Thanks & Regards,
Chandu |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
¿SQLCODE -4700? If I'm not wrong that's not a valid sqlcode... |
|
Back to top |
|
|
chandu.be
New User
Joined: 17 Jul 2006 Posts: 9 Location: Bagalore
|
|
|
|
Hi Acevedo,
SQLCODE -4700 is a valid code.
SQLCODE -4700 says that 'ATTEMPT TO USE NEW FUNCTION BEFORE NEW FUNCTION MODE'
Thanks & Regards,
Chandu |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
This happens if you are using DB2 version 8 ... contact ur DBA and tell them to activate the new function mode or else try binding the program
with parameter NEWFUN(YES) ... |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
yes, here we have versin 7 and this is what you get when invoke dsntiar with -4700.
Code: |
DSNT413I SQLCODE = -4700 INVALID SQLCODE |
|
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Hi,
chandu.be wrote: |
Hi,
UPDATE B
SET COL3 = (SELECT COL3
FROM A WHERE A.COL1 = B.COL1 AND A.COL2 = B.COL2
AND A.COL3 <> B.COL3);
But it is giving me SQLCODE -4700.
|
I suppose you need to join tables A and B.
Code: |
UPDATE B
SET COL3 = (SELECT COL3
FROM A
,B
WHERE A.COL1 = B.COL1 AND
A.COL2 = B.COL2 AND
A.COL3 <> B.COL3);
|
Hope this works. |
|
Back to top |
|
|
|