Subject Re: Updating a timestamp field
Author Alexander V.Nevsky
--- In ib-support@y..., Helen Borrie <helebor@t...> wrote:
> If you want to use the timestamp literal 'NOW' you must include it
in
> single quotes and (in Dialect 3) cast it explicitly. The
SQL-compliant
> server context variable CURRENT_TIMESTAMP might be simpler. They
are
> interchangeable.

Helen, there was discussion on this subject out there on difference
between CURRENT_TIMESTAMP and 'NOW'. Just now in FB CURRENT_TIMESTAMP
is fixed on start of trigger's execution? client statement? and 'NOW'
is'nt. Look at the example:

CREATE TABLE TEST_TS_N (
TIMESTAMP1 TIMESTAMP,
TIMESTAMP2 TIMESTAMP,
NOW1 TIMESTAMP,
NOW2 TIMESTAMP,
ID INTEGER);

Create Trigger TEST_TS_N_BI For TEST_TS_N Before Insert
As
Declare Variable I INT;
begin
NEW.TIMESTAMP1=CURRENT_TIMESTAMP;
NEW.NOW1=CAST('NOW' AS TIMESTAMP);
I=0;
WHILE (I<1000000) DO
I=I+1;
NEW.TIMESTAMP2=CURRENT_TIMESTAMP;
NEW.NOW2=CAST('NOW' AS TIMESTAMP);
end

select * from TEST_TS_N

TIMESTAMP1 31-OCT-2002 19:20:58
TIMESTAMP2 31-OCT-2002 19:20:58
NOW1 31-OCT-2002 19:20:58
NOW2 31-OCT-2002 19:21:04
ID 0

I don't know is it bug or as designed. I incline to treat it as
CURRENT_TIMESTAMP bug, old 'NOW' behaviour is more evident. Comments?

Best regards, Alexander V.Nevsky.