Thread: problems with date

problems with date

From
Jamie Deppeler
Date:
Hi,

having a small problem in a trigger i want to automatically update a
date field but when i use for example

update table
set field = current_date
where table.pk = new.pk

or

update table
set field = now()
where table.pk = new.pk

this crashes think link between server and db, i have tried using these
commands on a command line and they work ok

thanks for any help again

JD

Re: problems with date

From
Richard Huxton
Date:
Jamie Deppeler wrote:
> Hi,
>
> having a small problem in a trigger i want to automatically update a
> date field but when i use for example
>
> update table
> set field = current_date
> where table.pk = new.pk

If "table" is the table with the trigger on it, you'll end up with an
endless loop, since the trigger will keep firing itself.

In a BEFORE trigger, just update NEW and make sure you return NEW. Look
at the example in the manual for details.

--
   Richard Huxton
   Archonet Ltd