INSERT and UPDATE triggers passing null for both oldRow and newRow in fire(...)

361 views
Skip to first unread message

loki der quaeler

unread,
Apr 11, 2012, 3:37:13 PM4/11/12
to h2-da...@googlegroups.com
Hello -

I'm running version 1.3.166 of H2 from within a Java process running on Windows 7 64 bit; the java version is 1.6.0_22 / 17.1-b03 -- though i'm trapped into this version by application requirements.

I start a PG server within my Java process (Server.createPgServer("-baseDir", "~")).

Elsewhere in the OS, i have some functionality written in C# which is using the PostgreSQL 64-bit Unicode ODBC driver, version 9.01.01.00.

SELECT-ing, INSERT-ing, UPDATE-ing via the ODBC DSN is working fine as far as manipulating the data within the H2 db, however when any of the following triggers fire:
  CREATE TRIGGER IF NOT EXISTS selection_trigger AFTER INSERT ON selection_export_complete CALL "com.xxx.xxx.xxx.SelectionUpdateTrigger";
  CREATE TRIGGER IF NOT EXISTS selection_trigger_b BEFORE INSERT ON selection_export_complete CALL "com.xxx.xxx.xxx.SelectionUpdateTrigger";
  CREATE TRIGGER IF NOT EXISTS selection_trigger_c AFTER UPDATE ON selection_export_complete CALL "com.xxx.xxx.xxx.SelectionUpdateTrigger";

both oldRow and newRow in my implemented method

   public void fire (Connection conn, Object[] oldRow, Object[] newRow) throws SQLException { ... }

are null. I inferred from the documentation that at least one of these two should be containing useful information... ?

Any ideas about where i can look to troubleshoot this problem?

Thanks in advance.

Rami Ojares

unread,
Apr 11, 2012, 3:58:07 PM4/11/12
to h2-da...@googlegroups.com
You need to add FOR EACH ROW
The default is FOR EACH STATEMENT (== empty string)
In H2's current implementation if you use FOR EACH STATEMENT then oldRow
and newRow will always be null.
This is not documented but just a simple fact of life.

- Rami

> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/pFsOr-wxyCYJ.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.

loki der quaeler

unread,
Apr 11, 2012, 4:31:39 PM4/11/12
to h2-da...@googlegroups.com

Thanks so much - worked as expected
Reply all
Reply to author
Forward
0 new messages