Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DB2 update query - Single query to update many rows

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
op

New User


Joined: 31 Oct 2006
Posts: 48
Location: Chennai

PostPosted: Tue Nov 06, 2007 12:18 am    Post subject: DB2 update query - Single query to update many rows
Reply with quote

Hi,

I do have some doubt in a DB2 update query.

I want to update the field FLD1 based on another field FLD2 in the same table.

eg. if FLD2 is '1', FLD1 should be updated with '3'
if FLD2 is '5', FLD1 should be updated with '1'
if FLD2 is '4', FLD1 should be updated with '6'
if FLD2 is '9', FLD1 should be updated with '0'

i.e there is a 1-1 mapping between FLD1 and FLD2 values.

Can I do the update with a single update query.

Thanks & Regards.
Back to top
View user's profile Send private message

Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Tue Nov 06, 2007 1:02 am    Post subject:
Reply with quote

Easy enuf to test, but not as easy as asking someone else who may or may not know.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Nov 06, 2007 1:13 am    Post subject: Re: DB2 update query - Single query to update many rows
Reply with quote

op wrote:
Hi,

I do have some doubt in a DB2 update query.

I want to update the field FLD1 based on another field FLD2 in the same table.

eg. if FLD2 is '1', FLD1 should be updated with '3'
if FLD2 is '5', FLD1 should be updated with '1'
if FLD2 is '4', FLD1 should be updated with '6'
if FLD2 is '9', FLD1 should be updated with '0'

i.e there is a 1-1 mapping between FLD1 and FLD2 values.

Can I do the update with a single update query.

Thanks & Regards.


I don't think you can do it with a single update.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Tue Nov 06, 2007 1:18 am    Post subject:
Reply with quote

case statement?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us