Home Page for the TeradataForum
 
https:

Archives of the TeradataForum

Message Posted: Wed, 07 Mar 2012 @ 22:22:32 GMT


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


Subj:   Re: Insert When
 
From:   McCall, Glenn David

Isn't this just 2 insert statements?

The use of the VALUES (i.e. constant values) seems confusing in this scenario. Also, does the target table and column list have to be the same?

Can you supply a working example (I did find a couple of very bizarre example for Oracle - real example would be better)?

But I guess you could do this:

     INSERT
     INTO [TableName] ([ColumnName])
     VALUES ([VALUES])
     SELECT [ColumnName] FROM [TableName]
           Where ([Condition])
     ;
     INSERT
     INTO [TableName] ([ColumnName])
     VALUES ([VALUES])
     SELECT [ColumnName] FROM [TableName]
           Where NOT ([Condition])
     ;

If you have to use literal values you could use a macro as follows (check syntax, I just made this up):

     Replace macro x (i1 integer, i2 integer) as (
       Insert into target1 values (:i1, :i2)
       Where :i1 = 1;

       Insert into target2 values (:i1, :i2)
       Where :i1 <> 1;
     );


     ***** ALSO, the utilities (e.g. mload) has conditional processing that looks sort of like this (check the manual for syntax)

         .import ....

         APPLY INS_NO_1 where condition1
         APPLY INS_NO_2 where condition2
     Etc
     ;


     
  <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: 28 Jun 2020