SunQuest
           DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 22nd, 2007, 05:14 PM
lullo lullo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 lullo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 23 sec
Reputation Power: 0
Update multi-values

Hi,
I'm trying to update a table's column. the values are taken from a join with 3 table. this join return to me 4 diferent values. I would like put this 4 values in my target table's column. It's possible?

following there is my code:

UPDATE DBFN01.CLIENT_BD_TOTAL AS TC
SET TC.PERCCOERNOTCOER =
(
SELECT (PERCENTAGE-T.PERCTOTASSETCLASS) PERCCOERNOTCOER
FROM DBFN01.CLIENT_BD_TOTAL T
LEFT OUTER JOIN(
SELECT * FROM DBFN01.CLIENT_BD_TOTAL T ,
DBFN01.RPFPFMMULBANKID RPF,
DBFN01.PFMASSCLASSBDENTRY P
WHERE RPF.PROFILEID=T.RISKPROFILEID AND RULEID=1
AND RPF.PTFID=P.PTFID AND T.ASSETCLASSID=P.ID) TEST
ON (T.EXTERNALID=TEST.EXTERNALID)
WHERE T.ACLEVEL =2 AND T.EXTERNALID = '001994275_REF'
)

thk

Reply With Quote
  #2  
Old January 23rd, 2007, 11:30 AM
LKBrwn_DBA LKBrwn_DBA is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 294 LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 16 h 48 m 15 sec
Reputation Power: 9
Thumbs down

Quote:
Originally Posted by lullo
...this join return to me 4 diferent values. I would like put this 4 values in my target table's column. It's possible?


If you can fit both your feet and both your hands into one shoe, It might be possible.


Reply With Quote
  #3  
Old January 23rd, 2007, 09:56 PM
fractalvibes fractalvibes is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Location: Waco, Texas
Posts: 632 fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 14 h 11 m 13 sec
Reputation Power: 22
Quote:
Originally Posted by LKBrwn_DBA

If you can fit both your feet and both your hands into one shoe, It might be possible.



Normally you would do your select of the three tables first, save off the values you want, and then proceed with a separate update. Take a look at the DB2 Cookbook(s):
http://mysite.verizon.net/Graeme_Birchall/id1.html
It may be possible to do your update, but you might want to do a nested table join on the latter part. What result do you get when you execute the SQL you posted?

fv
__________________
...because that is the way we have always done it. We've been doing it like that for 80 Years! (How do we change that mindset?)

Reply With Quote
  #4  
Old January 24th, 2007, 02:26 AM
lullo lullo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 lullo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 23 sec
Reputation Power: 0
in my previews query my resultset was a record of 4 values, but now change my idea.. the concept is select a range of values and put them in my target table column using a 'where' condition to match the values.

this is my new query, but the sysntax is not correct for bd2

UPDATE DBFN01.CLIENT_BD_TOTAL AS TC,
(SELECT (PERCENTAGE-T.PERCTOTASSETCLASS) AS PERCCOERNOTCOER,T.EXTERNALID,T.INSTITUTIONID,T.ASSETCLASSID,T.ACLEVEL
FROM DBFN01.CLIENT_BD_TOTAL T
LEFT OUTER JOIN(
SELECT * FROM DBFN01.CLIENT_BD_TOTAL T ,DBFN01.RPFPFMMULBANKID RPF,DBFN01.PFMASSCLASSBDENTRY P
WHERE RPF.PROFILEID=T.RISKPROFILEID AND RULEID=1 AND RPF.PTFID=P.PTFID AND T.ASSETCLASSID=P.ID) TEST
ON (T.EXTERNALID=TEST.EXTERNALID AND T.INSTITUTIONID = TEST.INSTITUTIONID
)
) AS TC2
SET TC.PERCCOERNOTCOER = TC2.PERCCOERNOTCOER
WHERE T.ACLEVEL =2
AND TC.EXTERNALID = TC2.EXTERNALID
AND TC.INSTITUTIONID = TC2.INSTITUTIONID
AND TC.ASSETCLASSID = TC2.ASSETCLASSID
AND T.EXTERNALID = '001994275_REF'


any idea.

cheers
d

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > Update multi-values


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway