Subject Re: [firebird-support] Re: Making evaluation of UDFs constant across a query
Author Helen Borrie
At 08:08 AM 22/03/2011, Michael Ludwig wrote:
>
>> CURRENT_TIMESTAMP context is the CURRENT_TRANSACTION
>> Date literal 'NOW' context is the executing statement
>> UDF GetExactTimestamp() refreshes with each call to the function
>
>I don't get it.
>
> select
> current_timestamp,
> cast( 'now' as timestamp )
> from rdb$database;
>
>Both values are always identical, as I thought.

That should not be surprising. You have a single statement there in a single transaction.


>I (mis)understood your statement as saying that CURRENT_TIMESTAMP
>remains constant during a transaction (which of course it doesn't)

Yes, it does.

>whereas 'NOW' remains constant during a single executing statement
>(which it probably does).

Correct.


>So what is the *context* you're referring to in the above statement
>and how do CURRENT_TIMESTAMP and 'NOW' differ in that respect?

As indicated already.

Test them separately. Hint, write a SP that processes two statements like your example. Note also that, in Fb 1.5 or a dialect 1 database, the differences may be invisible, since current_timestamp and 'NOW' both return sub-seconds as .0000 and most simple SELECTs like your example are sub-second in duration. Check the v.2.0 release notes for the changes (improvements) introduced in v.2.0.

./heLen


./heLen