Subject | Re: [ib-support] Updating a timestamp field |
---|---|
Author | Helen Borrie |
Post date | 2002-10-31T12:57:44Z |
At 12:35 PM 31-10-02 +0000, you wrote:
single quotes and (in Dialect 3) cast it explicitly. The SQL-compliant
server context variable CURRENT_TIMESTAMP might be simpler. They are
interchangeable.
Here are the two syntaxes (used in triggers, which is the common way to
timestamp inserts and updates):
create trigger bu_mytable
active before update position 0
as
begin
new.TIMESTAMP_SENT = CURRENT_TIMESTAMP;
end
create trigger bi_mytable
active before insert position 0
as
begin
new.TIMESTAMP_ADDED = cast('Now' as TIMESTAMP);
end
heLen
>I have a table with two timestampsIf you want to use the timestamp literal 'NOW' you must include it in
>
> TIMESTAMP_ADDED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
> TIMESTAMP_SENT TIMESTAMP
>
>When I update the TIMESTAMP_SENT field, I'd like to use the time on
>the server, rather than passing in the (possibly incorrect)client's
>time/date.
>
>Can I do something like this:
>
>UPDATE myTable(TIMESTAMP_SENT)
>VALUES( NOW() )
>
>or, would I have to do this as a SP in order to get the server time?
single quotes and (in Dialect 3) cast it explicitly. The SQL-compliant
server context variable CURRENT_TIMESTAMP might be simpler. They are
interchangeable.
Here are the two syntaxes (used in triggers, which is the common way to
timestamp inserts and updates):
create trigger bu_mytable
active before update position 0
as
begin
new.TIMESTAMP_SENT = CURRENT_TIMESTAMP;
end
create trigger bi_mytable
active before insert position 0
as
begin
new.TIMESTAMP_ADDED = cast('Now' as TIMESTAMP);
end
heLen