IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Update into one table using certain values from other table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jagankallis
Warnings : 1

New User


Joined: 28 Jun 2006
Posts: 29
Location: DUISBURG

PostPosted: Thu Aug 31, 2006 11:26 pm
Reply with quote

Dear All,

I want to . Please give me enough sample examples for this scenario.

Thanks a lot in advance for your co-operation
Back to top
View user's profile Send private message
Gautam512

Active User


Joined: 05 Oct 2005
Posts: 308
Location: Vizag / US

PostPosted: Fri Sep 01, 2006 6:17 am
Reply with quote

hi,

there are so many ways , but one way which is a bit simple is:

u can get the details from the other table first and copy them into the host variables for the insertion of data.
Back to top
View user's profile Send private message
Muthukumar.PLindia

New User


Joined: 03 Jul 2006
Posts: 51
Location: Chennai

PostPosted: Fri Sep 01, 2006 6:42 am
Reply with quote

If both of the tables are in same system, You can try inserting a row like this

Insert into table1 (select * (or) field1, field2 from table2)

If you want to update the existing rows from the values taken into other table, then i dint tried this type of query..... let me check it any info you
Back to top
View user's profile Send private message
jagankallis
Warnings : 1

New User


Joined: 28 Jun 2006
Posts: 29
Location: DUISBURG

PostPosted: Fri Sep 01, 2006 3:49 pm
Reply with quote

Dear All,

I explain in more details manner my requirement

Please find the below query

SELECT RKT_ID,RKT.GES_SALDO, XVIEW.GES_SALDO,XVIEW.CODE,
DATE(XVIEW.UMS_TS),XVIEW.BETRAG
FROM RKT RKT,
(
SELECT UMS.SYS_ID,UMS.GES_SALDO,UMS.KAP_SALDO,UMS.KST_SALDO,
UMS.ZSS_SALDO,UMS.UMS_TS, UMS.CODE, UMS.BETRAG
FROM UMS
WHERE UMS.UMS_TS IN (SELECT MAX(X.UMS_TS)
FROM UMS X
WHERE X.SYS_ID = UMS.SYS_ID)
) XVIEW
WHERE RKT.RKT_ID = XVIEW.SYS_ID
AND RKT.GES_SALDO <> XVIEW.GES_SALDO
AND DATE(XVIEW.UMS_TS) > '23.08.2006'
ORDER BY RKT_ID
WITH UR
;

Now my requirement is to

update the value XVIEW.GES_SALDO (refer above query resultant) into the UMS.GES_SALDO (UMS table) table for the above criterion.

Please let me know if more information need to be given for explanation.
Back to top
View user's profile Send private message
jagankallis
Warnings : 1

New User


Joined: 28 Jun 2006
Posts: 29
Location: DUISBURG

PostPosted: Thu Sep 07, 2006 7:51 pm
Reply with quote

Dear All,

I explain in more details manner my requirement

Please find the below query

SELECT RKT_ID,RKT.GES_SALDO, XVIEW.GES_SALDO,XVIEW.CODE,
DATE(XVIEW.UMS_TS),XVIEW.BETRAG
FROM RKT RKT,
(
SELECT UMS.SYS_ID,UMS.GES_SALDO,UMS.KAP_SALDO,UMS.KST_SALDO,
UMS.ZSS_SALDO,UMS.UMS_TS, UMS.CODE, UMS.BETRAG
FROM UMS
WHERE UMS.UMS_TS IN (SELECT MAX(X.UMS_TS)
FROM UMS X
WHERE X.SYS_ID = UMS.SYS_ID)
) XVIEW
WHERE RKT.RKT_ID = XVIEW.SYS_ID
AND RKT.GES_SALDO <> XVIEW.GES_SALDO
AND DATE(XVIEW.UMS_TS) > '23.08.2006'
ORDER BY RKT_ID
WITH UR
;

Now my requirement is to

update the value XVIEW.GES_SALDO (refer above query resultant) into the UMS.GES_SALDO (UMS table) table when the UMS.SYS_ID = XVIEW.SYS_ID

Please let me know if more information need to be given for explanation.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
Search our Forums:

Back to Top