Subject Re: [IBO] IB_query default value property
Author Helen Borrie
At 01:51 AM 30/06/2003 +0000, you wrote:
>I wonder if IB_query can accept this ... If I have a date field in my
>IB_query, can I set its default value property to "current date"
>or "now" or expression?

It is not a good idea to use the client-local (Delphi) date variables for
date/time stamping or for calculating derived values that are going to be
stored in the database. These variables in the client application will
record the date/time on the client machine, not the server. This makes the
stamping unreliable in a mult-user environment.

The safe thing to do is to write Before Insert and Before Update triggers
on the table that is to get the timestamp. You still have access to
date/time variables, and they are local to the server. Here's an example:

CREATE TRIGGER TIMESTAMP_CUSTOMER FOR CUSTOMER
ACTIVE BEFORE INSERT POSITION 0 AS
[[[[ ACTIVE BEFORE UPDATE POSITION 0 AS ]]]]
BEGIN
NEW.DATE_STAMP = CURRENT_DATE;
/* or, alternatively --- */
[[[[ NEW.DATE_STAMP = CAST ('TODAY' AS DATE);]]]]
END

Helen