[h2] Re: Updating a current column with an old column using triggers without exception StackOverflowError

2024-03-28 Thread Paulo Destro
0


You must write your trigger with *AFTER* SQL statement
CREATE TRIGGER update_timestamp_trigger AFTER UPDATE ON public.bill FOR 
EACH ROW CALL "loop.update.trigger.UpdateTimestamp"; 

I was using BEFORE

Em quarta-feira, 27 de março de 2024 às 13:45:28 UTC-3, Paulo Destro 
escreveu:

> I'm trying to update a column using the old row with triggers. But when I 
> try updating the trigger loops infinitelly. I have the same exemple with 
> updating timestamp on my github.[image: IMG-20240327-WA.jpg]
>
> https://github.com/pddec/loop
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/e0e20508-2d27-4755-9f4c-901a6fc9c182n%40googlegroups.com.


[h2] Re: Updating a current column with an old column using triggers without exception StackOverflowError

2024-03-27 Thread Evgenij Ryazanov
Hello!

If you need to modify this row in your trigger, you must change values in 
the newRow array directly:

newRow[/* 0-based column index */] = OffsetDateTime.now();

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/136b7d23-0894-4e1a-b913-a51a5553bf3dn%40googlegroups.com.