Subject Deferring Constraint Checking
Author Jack Frosch
Is it possible to configure Firebird to defer constraint checking
until a commit?

I'm using Firebird on a J2EE Enterprise JavaBeans (EJB) application
using the JBoss application server. Because of the peculiarities of
EJB and JBoss, I'm wanting to defer the constraint checking until the
transaction is committed. I've been told Oracle will allow this, so I
thought I'd ask if Firebird/FirebirdSQL has such a configuration
option.

FYI Background: In EJB, the insert of a row is performed in an
ejbCreate method, then the relationhip between one entity and another
is configured in the ejbPostCreate method. The problem is,
Firebird/FirebirdSQL is checking the constraint immediately on the
INSERT of the row (in the ejbCreate method) before JBoss ever gets a
chance to manage the relationship. At that point, the value for the
foreign key column, which is NOT NULL, is null, and an exception is
thrown.

In pseudo-SQL, what I think the app server wants to do is something
like this:

// ejbCreate method does this
INSERT INTO childTable ... (no value for FK column)

// ejbPostCreate method does this
UPDATE childTable ... (set FK column value to non null)

// commit causes constraints to be checked
COMMIT;