INSERT TRIGGER to convert UNIX date time to DATE
Posted in 2000
Topics: Triggers, Constraints & Referential Integrity
Hi,
I have a table with a DATE field named COLLECTION_DATE. The table is
updated by and application which stores a UNIX date time into the
COLLECTION_DATE field. I would like to modify the input date via a TRIGGER
to convert it to the INFORMIX date format. I wrote the trigger below.
CREATE TRIGGER DM_METRICS_INSERTINSERT ON DM_METRICS
FOR EACH ROW(
UPDATE DM_METRICS
SET COLLECTION_DATE = COLLECTION_DATE / 86400 + 71);
Will this trigger do the propper conversion from UNIX datetime to INFORMIX
date when I insert into the DM_METRICS table?
John
John Ruggentaler wrote on Tue, 29 Feb 2000 11:29:35 -0600:
> Hi,
> I have a table with a DATE field named COLLECTION_DATE. The table is
> updated by and application which stores a UNIX date time into the
> COLLECTION_DATE field. I would like to modify the input date via a TRIGGER
> to convert it to the INFORMIX date format. I wrote the trigger below.
>
> CREATE TRIGGER DM_METRICS_INSERT> INSERT ON DM_METRICS
> FOR EACH ROW(
> UPDATE DM_METRICS
> SET COLLECTION_DATE = COLLECTION_DATE / 86400 + 71);
>
> Will this trigger do the propper conversion from UNIX datetime to INFORMIX
> date when I insert into the DM_METRICS table?
>
> John
>
>
Hi John,
I just wonder if this trigger will work, AFAIK you cannot modify a column
of the table which is fireing the trigger, because the insert transaction
is still running when you try to modify it.
Andreas