Hi Gabriele,
One way to solve this problem would be to have your trigger call a
database procedure, passing in whatever parameters you need from the
triggering row. The procedure would run the sanity check query and raise
an exception if the sanity check failed.
Hope this helps,
-Rick
Gabriele Kahlout wrote:
Hello,
I'm porting my application from SQLite to Java DB, but don't know how
to enforce an assertion, achieved in SQLite by:
st.execute("CREATE TRIGGER _fk_meanings_update_1 BEFORE UPDATE ON " +
batTable.getName() + " FOR EACH ROW BEGIN SELECT RAISE(FAIL, 'error')
WHERE (EXISTS (SELECT COUNT(*) FROM " + batTable.getName() + " GROUP
BY " + lastPubColumn.getName() + " HAVING COUNT(*)>"+maxPub+"));
END;");
However the constraint couldn't be added as a table constraint, and
I'm not finding how to raise an exception with Java DB, although it's
described here:
http://developers.sun.com/docs/javadb/10.5.3.0/devguide/index.html
One way was to set the identity column to null, but that was not
allowed at compile time too. I guess I'd have to use some dirty way.