Re: Current function within a Stored Procedure.
Posted in 1998
Viegas, John wrote:
>
> Here's a synopsis of the problem I'm trying to solve:
>
> I have a table (table_a) with two datetime columns (start_time,
> end_time).
>
> At the beginning of a stored procedure, I want to insert a row into
> table_a setting start_time to the current datetime. The stored
> procedure then executes a bunch of other statements that take up to
> several hours to execute. At the end of the procedure, I want to update
> table_a end_time to the current datetime (different than the start
> datetime). Because the Informix 'current' function in a stored
> procedure returns only one value, I'm having trouble registering the two
> different times.
>
> Do you know of any work-arounds.
Better to create an UPDATE trigger for the table that sets the end_date
column for you:
CREATE TRIGGER FOR UPDATE OF (start_time) ON mytable
REFERENCING OLD AS finish FOR EACH ROW
UPDATE mytable SET end_time = CURRENT
WHERE mytable.start_time = finish.start_time;
Then you can just:
UPDATE mytable SET start_time = start_time WHERE start_time = CURRENT;
in the procedure.
Art S. Kagel