Subject Re: [IBO] Simple trigger question
Author Helen Borrie
At 06:58 AM 22-10-01 -0400, Bob Jones wrote:
>Anyone know the syntax for creating a trigger to update a date field with
>the current date when a record is modified?
>
>This is what I thought it should be, but I'm having trouble with the date
>value. Also haven't been able to find it in the help file. Any assistance
>would be appreciated.
>
>SET TERM ^ ;
>CREATE TRIGGER "SET_PAT_DATE" FOR "PATIENT"
>BEFORE UPDATE
>as begin
> new.PA_UPDATED = date;
>end
> ^

Dialect 3:
new.PA_UPDATED = CURRENT_DATE; /*if the column is a dialect 3 DATE type */
CURRENT_TIMESTAMP /* TIMESTAMP type */

Others:
Dialect 1:
new.PA_UPDATED = cast('Now' as date); (or cast('today' as date))

IB 5 and below:

new.PA_UPDATED = 'Now'; (or 'Today')

H.


All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________