Subject OBJECT in use during Foreign key creation
Author Robert DiFalco
I have these strings of DDL in an array....

CREATE TABLE ClassInfo (id INTEGER NOT NULL,classname BLOB SUB_TYPE 1
NOT NULL,strategy BLOB SUB_TYPE 1 NOT NULL,codebase BLOB SUB_TYPE 1 NOT
NULL,PRIMARY KEY(id) );

CREATE PROCEDURE insertClassInfo(nId INTEGER,sClassname BLOB SUB_TYPE
1,sStrategy BLOB SUB_TYPE 1,sCodebase BLOB SUB_TYPE 1) AS BEGIN INSERT
INTO ClassInfo(id,classname,strategy,codebase) VALUES
(:nId,:sClassname,:sStrategy,:sCodebase); END

CREATE TABLE Named ( id INTEGER NOT NULL,name VARCHAR(64),description
BLOB SUB_TYPE 1,version INTEGER NOT NULL,classInfoId INTEGER NOT
NULL,PRIMARY KEY(id) );

ALTER TABLE Named ADD CONSTRAINT FK_ClassInfo FOREIGN KEY ( classInfoId
) REFERENCES ClassInfo ( id );

When I try to execute the last line I hang in JayBird and in Firebird I
get an "unsuccessful metadata update; Object CLASSINFO is in use".

Anybody have any idea what I might be doing wrong?

My code essentially looks like this:


Connection con = ConnectionFactory.createConnection();
createTables( con, <array of four strings as above> );
con.close();

void createTables( Connection con, String[] ddl ) throws Exception
{
Statement statement = con.createStatement();
for ( int at = 0; at < ddl.length; ++at )
{
if ( Persistence.DEBUG )
System.out.println( ddl[ at ] );

statement.executeUpdate( ddl[ at ] );
}
}


TIA for you help.

R.