Hi,

I'm defining a H2 trigger with the following command

CREATE TRIGGER MY_TRIGGER BEFORE INSERT ON MY_TABLE AS $$
    org.h2.api.Trigger create() {
        return new org.h2.api.Trigger() {

            @Override
            public void remove() throws SQLException {
            }

            @Override
            public void init(Connection conn, String schemaName, String 
triggerName, String tableName, boolean before,
                int type) throws SQLException {
            }

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

            @Override
            public void close() throws SQLException {
            }
        };

    } $$;


I added the h2-1.3.173.jar archive to the CLASSPATH environment variable, 
but when I try to execute the command to actually create the trigger (I'm 
using DBeaver) I get this error.


SQL Error [90043] [90043]: Error creating or initializing trigger 
"MY_TRIGGER" object, class "..source..", cause: "org.h2.message.DbException: 
Syntax error in SQL statement ""
    org.h2.api.Trigger create() {
        return new org.h2.api.Trigger() {


            @Override
            public void remove() throws SQLException {
            }


            @Override
            public void init(Connection conn, String schemaName, String 
triggerName, String tableName, boolean before,
                int type) throws SQLException {
            }


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


            @Override
            public void close() throws SQLException {
            }
        };


    } "" [42000-193]"; see root cause for details; SQL statement:


    [...]


    Syntax error in SQL statement "
    org.h2.api.Trigger create() {
        return new org.h2.api.Trigger() {


            @Override
            public void remove() throws SQLException {
            }


            @Override
            public void init(Connection conn, String schemaName, String 
triggerName, String tableName, boolean before,
                int type) throws SQLException {
            }


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


            @Override
            public void close() throws SQLException {
            }
        };


    } " [42000-193]
          java.lang.NullPointerException: 



Now, what could be the problem? I followed the syntax in the official guide 
<http://www.h2database.com/html/grammar.html#create_trigger> regarding 
inline definition of trigger code.

Thank you
Giulio

-- 
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 post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to