Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 965
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: 965
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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Conditional highlighting of rows in I... packerm CLIST & REXX 2 Thu Sep 21, 2017 6:50 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us