Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 06 Mar 2003 @ 20:54:00 GMT


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


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

I have not had huge experience with triggers, but try this little example. Keep running the insert and the select * to see if it does what you want. Then keep reading.

create table x (seq integer, str varchar (100))
;

insert into x (seq, str)
select seq, 'the string ' || seq
from (
    select zeroifnull(max (seq)) + 1
    from x
    ) as nxtseq (seq);

select * from x;

Then... Could you not wrap it in something like this example taken from the V2R4 manual?

CREATE TRIGGER RaiseTrig
AFTER UPDATE OF (Salary) ON Employee
REFERENCING OLD AS OldRow NEW AS NewRow
FOR EACH ROW
WHEN ((NewRow.Salary-OldRow.Salary)/OldRow.Salary>.10)
(
/************************ Ditch this ... */
    INSERT INTO SalaryLog
    VALUES (USER, NewRow.Name, OldRow.Salary,
    NewRow.Salary);
/************************ and put my/your insert here */);

Obviously you need to code the trigger so that it contains your specific trigger condition, but it should work with some tweaking.


God Luck

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