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 > Loading tables from other tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-07-07, 20:33
atulxp atulxp is offline
Registered User
 
Join Date: Jun 2007
Posts: 2
Loading tables from other tables

Could you please help me in this, In a script if I want to do following

I have two set of tables.

Table_T1

Table_T2_1, Table_T2_2, Table_T2_4, Table_T2_5,Table_T2_6

Each table in table set Table_T2_* contain data for one month only whereas table table_T1 contain data for multiple months.

I want to select Year & month from each of Table_T2_* & check if any record for that year month in Table T1

If yes then Insert those record in that table by load from cursor into respective table Table_T2_* . I want to do that in loop.

Ex:-

Suppose Table_T2_1 contain data for May-2005 so I need to load all May 2005 data from table Table_T1 to Table_T2_1, similarly if Table_T2_2 contain data for Nov-2005 then pick all records for Nov_2005 from Table_T1 & insert in Table_T2_2.

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 06-08-07, 08:24
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
I am not sure I got exactly what you are after, but the select for the cursor might look like: (this is assuming that your month and year ae separate column named amonth and ayear).

select * from table_t1 where (ayear,amonth) in (select ayear,amonth from table_t2_1)

You would have a similiar statement fore each table table_t2_*.

Andy
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