Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 06 Mar 2003 @ 22:38:03 GMT


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


Subj:   Re: Sequence #
 
From:   McCall, Glenn D

I had to mess with it a bit, but the key lies in using a table (new_table) clause in the trigger and joining the table to my derived table.

Here is what I got to work using my original example.

Create trigger tmp1_ins_trig enabled after insert on Tmp1 order 1
/* User new_table */
  referencing new_table as Nrow
/* And now we need for each STATEMENT */
  for each statement
  (
    Insert into tmp2 (
             SeqNbr
            ,Col1
            ,Col2
            ,Col3
           )
    Select    nxtSeq.Seq
            ,NRow.Col1
            ,Nrow.Col2
            ,Nrow.Col3
/* And simply join the new table to my derived table for the sequence
number
*/
    from    nRow cross join (
    select zeroifnull(max (seqnbr)) + 1
    from tmp2
    ) as nxtseq (seq)
    ;
  );

Hope this helps

Glenn Mc



     
  <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