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

DB2 update query - Single query to update many rows


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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

Senior Member


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

PostPosted: Tue Nov 06, 2007 1:02 am
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
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

Senior Member


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

PostPosted: Tue Nov 06, 2007 1:18 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts RC query -Time column CA Products 3
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Dynamically pass table name to a sele... DB2 2
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top