Updating a current column with an old column using triggers without exception StackOverflowError

44 views
Skip to first unread message

Paulo Destro

unread,
Mar 27, 2024, 12:45:28 PMMar 27
to H2 Database
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.IMG-20240327-WA0000.jpg

Evgenij Ryazanov

unread,
Mar 27, 2024, 8:13:43 PMMar 27
to H2 Database
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();

Paulo Destro

unread,
Mar 28, 2024, 2:03:38 AMMar 28
to H2 Database
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

Reply all
Reply to author
Forward
0 new messages