If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Mass update statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-01-04, 13:45
dsusendran dsusendran is offline
Registered User
 
Join Date: Apr 2004
Location: Inside Intel
Posts: 165
Exclamation Mass update statement

Is there a syntax error with this statement? It failed!

update CONTACT CNT set

CNT.ADDRESS_1_ID =
(
select
CA.CONTACT_ADDRESS_ID
from
CONTACT_ADDRESS CA
where
CA.CONTACT_ID = CNT.CONTACT_ID
)
where
CNT.ADDRESS_1_ID is null;

Thanks in advance,

:?
Newbie
Reply With Quote
  #2 (permalink)  
Old 06-01-04, 13:56
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
See if this thread helps
Update Statment
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 06-01-04, 14:14
dsusendran dsusendran is offline
Registered User
 
Join Date: Apr 2004
Location: Inside Intel
Posts: 165
Arrow

Sathyaram,

Thanks as usual for the prompt reply. I did alter my statement to

Code:
update CONTACT CNT set ADDRESS_1_ID = (select CA.CONTACT_ADDRESS_ID from CONTACT_ADDRESS CA, CONTACT CNT where CA.CONTACT_ID = CNT.CONTACT_ID);

It gave me an

Error:
SQL0104N An unexpected token "set" was found following "<identifier>".
Expected tokens may include: "USING". SQLSTATE=42601

Any pointers? TIA.

~ Newbie
Reply With Quote
  #4 (permalink)  
Old 06-01-04, 14:56
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
I think that is bit misleading ...

Try this:

update CONTACT CNT set ADDRESS_1_ID = (select CA.CONTACT_ADDRESS_ID from CONTACT_ADDRESS CA where CA.CONTACT_ID = CNT.CONTACT_ID);
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 06-02-04, 14:13
dsusendran dsusendran is offline
Registered User
 
Join Date: Apr 2004
Location: Inside Intel
Posts: 165
Arrow Sathyaram, Jim

Code:
update CONTACT CNT set ADDRESS_1_ID = (select CA.CONTACT_ADDRESS_ID from CONTACT_ADDRESS CA where CA.CONTACT_ID = CNT.CONTACT_ID);

did not work.

But
Code:
update CONTACT CNT set ADDRESS_1_ID = (select max(CA.CONTACT_ADDRESS_ID) from CONTACT_ADDRESS CA where CA.CONTACT_ID = CNT.CONTACT_ID);

worked, populating all the ADDRESS_1_ID column with same data (maximum of CONTACT_ADDRESS_ID ?! )

I know its weird, i am still curious if there was a way to dynamically update multiple records.

Thanks for all your help,

Newbie
Reply With Quote
  #6 (permalink)  
Old 06-02-04, 14:17
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Maybe I am wrong, but I thought there were some update enhancements in recent fixpaks. What release and fixpak are you on?
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #7 (permalink)  
Old 06-02-04, 14:28
dsusendran dsusendran is offline
Registered User
 
Join Date: Apr 2004
Location: Inside Intel
Posts: 165
Post

DB2 8.1.5 (fixpack 5) running on Windows 2000.

Is it possible? Any pointers in this regards would be really helpful.

Thanks,
Newbie
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On