Subject Re: [firebird-support] timestamp trigger?
Author Marcos Vinicius Dufloth
Em Qui, 2006-10-12 às 15:11 -0700, Fernando Salaices escreveu:

> Hello everyone.
>
> I need to have a timestamp that is updated every time a record is
> inserted or updated. I had asumed that just declaring the field as
> Timestamp this wold be acomplished but I was wrong. So a trigger
> (before update or insert) would be the next best thing. This is how I
> obtain the current date from firebird:
>
> select CURRENT_TIMESTAMP,
> from rdb$database;
>
> So I tried:
>
> select CURRENT_TIMESTAMP into NEW.MYTIMESTAMPFIELD,
> from rdb$database;
>
> did not work, so I tried:
>
> select CURRENT_TIMESTAMP into :NEW.MYTIMESTAMPFIELD,
> from rdb$database;
>
> Did not work either. So, can some one help me please? Is there another
> way to obtain an auto timestamp field?
>


the correct syntax is: select CURRENT_TIMESTAMP from RDB#DATABASE
into :MyTimeStampVar;



> Can a BEFORE UPDATE and a BEFORE UPDATE OR INSERT coexist? Because my
> table already has a BEFORE INSERT trigger.
>


yes. see also POSITION syntax for triggers.


Marcos Vinicius.


[Non-text portions of this message have been removed]