IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Update all the col4 values to match A table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chandu.be

New User


Joined: 17 Jul 2006
Posts: 9
Location: Bagalore

PostPosted: Thu Apr 24, 2008 4:09 pm
Reply with quote

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
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Thu Apr 24, 2008 4:19 pm
Reply with quote

¿SQLCODE -4700? If I'm not wrong that's not a valid sqlcode...
Back to top
View user's profile Send private message
chandu.be

New User


Joined: 17 Jul 2006
Posts: 9
Location: Bagalore

PostPosted: Thu Apr 24, 2008 4:32 pm
Reply with quote

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
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Apr 24, 2008 4:35 pm
Reply with quote

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
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Thu Apr 24, 2008 4:54 pm
Reply with quote

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
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Fri Apr 25, 2008 4:07 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
Search our Forums:

Back to Top