Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 30 Jul 2002 @ 14:33:39 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Macro Possibilities?
 
From:   Jim Downey

I think you will get a lot of response that a stored procedure will work for you. This does what you are asking for but not how you asked. There are two assumptions:

Your source comes from a finite number of tables.

The tables will always exist. (I assume the macro will fail if one does not exist at any point) It doesn't matter what state the table is in, it just needs to exist.

I am borrowing this from a select macro and it works fine. I hope the same holds true for insert/select. I don't have time to test it. This macro would allow you to call it in any of these ways:

exec insert_macro('T1'); will insert using T1 as the source.
exec insert_macro('T2'); will insert using T2 as the source
exec insert_macro('T1,T2'); will insert using both T1 and T2 as the source.

CREATE MACRO DB.Insert_Macro
(
Source_Table VARCHAR(30)
)
AS
(
Insert into DB.Target_Table
Select
col1, col2
From T1
where index('T1',:Source_Table)>0
;Insert into DB.Target_Table
Select
col1, col2
From T2
where index('T2',:Source_Table)>0
;
) --end macro
;



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023