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 > DB2: Update & Temporary Tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-30-06, 17:38
quadrokeith quadrokeith is offline
Registered User
 
Join Date: Mar 2006
Posts: 1
DB2: Update & Temporary Tables

Using db2 v 8.1.0.36 Fixpack 0 Windows XP SP2

Basically I want to run an update and using one statement I want to reuse data from a subquery.

So I have something like this currently:
update parent p
set p.field1 = case
when p.field2 = 1 and (select c.field1 from child c) = 'A'
then 'T'
when p.field2 = 2 and (select c.field1 from child c) = 'A'
then 'F'
end

This is obviously dumbed down, but the point is that I want to reuse the data from the (select c.field1 from child c) query so that I don't need to re-run it all the time and I want to be able to do it one command.

Is there a way, using updates, to do this? I know that with inserts you can use WITH VALUES for something like that, but that doesn't seem to work and I'm having difficulty finding the documentation for it - but something like how WITH VALUES works would work sufficiently. Any ideas?

Thanks,

Keith
Reply With Quote
  #2 (permalink)  
Old 03-30-06, 21:22
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
I am not sure in what fixpack that feature was added to DB2.

Regardless of features, each fixpack averages more than 300 fixes each, and we are now on fixpack 11, so that means IBM has fixed over 3,300 bugs since the version 8.1 base code (fixpack 0) was released. Fixpacks are free.
__________________
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
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