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: 968
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: 968
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 reg query on DYNALLOC feature raghuraman123 SYNCSORT 12 Wed Jan 10, 2018 2:42 pm
No new posts Conversion of DLI update Jobs as BMP ... Gopinath Shanmugam IMS DB/DC 3 Wed Dec 20, 2017 12:02 pm
No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Can we combine the rows with same key... V S Amarendra Reddy DB2 12 Fri Dec 01, 2017 10:29 pm

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