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 {
}
};
} $$;
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: 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:
CREATE TRIGGER MY_TRIGGER BEFORE INSERT ON CURRENT_APPLICATION_PROPERTY 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 {
}
};
} $$ [90043-193]
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:
CREATE TRIGGER MY_TRIGGER BEFORE INSERT ON CURRENT_APPLICATION_PROPERTY 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 {
}
};
} $$ [90043-193]
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]
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: --
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+unsubscribe@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.
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 Trig();
}
static class Trig implements 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:
CREATE TRIGGER MY_TRIGGER BEFORE INSERT ON MY_TABLE AS $$
org.h2.api.Trigger create() {
return new Trig();
}
static class Trig implements 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 {
}
}
$$ [90043-193]
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 Trig();
}
static class Trig implements 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:
CREATE TRIGGER MY_TRIGGER BEFORE INSERT ON MY_TABLE AS $$
org.h2.api.Trigger create() {
return new Trig();
}
static class Trig implements 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 {
}
}
$$ [90043-193]
Syntax error in SQL statement "
org.h2.api.Trigger create() {
return new Trig();
}
static class Trig implements 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]
Syntax error in SQL statement "
org.h2.api.Trigger create() {
return new Trig();
}
static class Trig implements 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: To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
You are not alone :-)
I also tried and failed. I came to the conclusion, that defining a trigger in source code can (currently) only be used to return a class that is already available on the class path.
With this restriction it seems pretty useless for pure H2 servers where you do not want to add additional jars to the classpath.
However, I did not take the time to analyze and provide a patch - so I should not complain...You are not alone :-)
I also tried and failed. I came to the conclusion, that defining a trigger in source code can (currently) only be used to return a class that is already available on the class path.
With this restriction it seems pretty useless for pure H2 servers where you do not want to add additional jars to the classpath.
However, I did not take the time to analyze and provide a patch - so I should not complain...
Am 10.04.2017 um 12:45 schrieb Giulio Vito de Musso:
HI all,--
no one can help me solve this issue? It's so strange that no one tried defining and executing a trigger inline with H2...
Regards
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-da...@googlegroups.com.