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 > Upadate using With Clause

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-28-08, 23:42
usDB2 usDB2 is offline
Registered User
 
Join Date: May 2008
Posts: 39
Upadate using With Clause

Hi

Can you please let me know syntax for using Update using with Clause.I am able to use insert with With Clause.But Update is not working .

Please help

Thanks
Reply With Quote
  #2 (permalink)  
Old 12-28-08, 23:57
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
Kindly explain in detail why you want to UPDATE using the WITH clause only and why not a simple UPDATE with JOIN......

It may be possible that you don't require the WITH clause in the first place.
__________________
IBM Certified Database Associate, DB2 9 for LUW
Reply With Quote
  #3 (permalink)  
Old 12-29-08, 00:45
usDB2 usDB2 is offline
Registered User
 
Join Date: May 2008
Posts: 39
Actually I am using 10 temporary tables and it involves a complicated logic.
So I cannot avoid using with clause.

Please advise
Reply With Quote
  #4 (permalink)  
Old 12-29-08, 06:18
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
You cannot use "WITH common table expression" clause in an UPDATE statement.

Please see syntax diagram of UPDATE statement
in "DB2 Version 9 for Linux, UNIX, and Windows SQL Reference Volume 2".
Reply With Quote
  #5 (permalink)  
Old 12-29-08, 08:00
usDB2 usDB2 is offline
Registered User
 
Join Date: May 2008
Posts: 39
Thanks so much.
As mentioned I have used with clause with 10 temp tables...
In my where condition of select clause I have a condition as mentioned below:

where (( x.account_sk =tm.account_sk and y.ACCOUNT_SK=tm.account_sk ) ---------------------(1)
or
x1.account_sk =tdt.account_sk and y1.account_sk=lft.account_sk ))---------(2)

If I give condition (1) ,(2) seperately it works fine,when I include or in between ,query doesnt return any result****ns for longer time

There is no cartesian product.

Please help
Reply With Quote
  #6 (permalink)  
Old 12-29-08, 16:06
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Have a look at the MERGE statement. This may be more suitable for you.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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