Re: INSERT Trigger
Posted in 1998
Topics: Triggers, Constraints & Referential Integrity
Roland, I wrote a reply to your newsgroup message and I have a modification. I wrote that you can't do it in a trigger, but could use a default column value by doing the following. (This assumes the column is of DATE type and is a NOT NULL column, basically the column gets the new definition as typed in the Alter Table statement including name, type and null-ability) Alter table <tablename> modify ( <date column name> DATE DEFAULT CURRENT NOT NULL); I have a change to this : Instead of using the default keyword CURRENT it may have to be TODAY (CURRENT is right if it's a DATETIME column). IMPORTANT: If you use the NOT NULL part then any currently NULL rows for this column may well get the current day's date in them (the date you run the statement). If you don't and it's NOT NULL now, you'll be modifying it to be NOT NULL. To INSERT, by the way, you just don't reference the column in your insert statement, it'll get it's default. -- Pete Bloxam Pete is a Database Administrator in a large UK Software house. Opinions are those of Pete and not of his employer. Roland Pich'r <rpichor@ddc.daewoo.com.pl> wrote in article <35EE465B.CE4B5852@ddc.daewoo.com.pl>... > Hi > > I've got following problem: > > I want to use trigger to set current date in row which I just insert (in > the same table) > > Any ideas how to do this (or just 'no way - it's impossible') ??? > > Thanks, > > Roland Pichor > rpichor@ddc.daewoo.com.pl > > >