Subject | Receiving an Object In Use error when adding an index to a table |
---|---|
Author | cdevlpr |
Post date | 2009-05-06T22:10:25Z |
Hi Everyone. I'm hoping someone can help me understand why I'm
getting a "lock conflict on no wait transaction.....object XXX is in
use" error when I'm trying to add an index to a table. I have a
short contrived example that demonstrates this issue. Basically...I
have a TIBODatabase object that is shared by two TIBOTable objects
which reference the same table in my database. I insert a record
using the first table object and free the object. Then...in a
separate transaction, I attempt to create an index on the same table
using my second TIBOTable object. When I try to commit the
transaction I get the error "lock conflict on no wait transaction
unsuccessful metadata update object XXXXX is in use". If I use an
TIB_Connection object instead of a TIBODatabase object this error
does not occur. As I understand it...we should never mix DDL and DML
in the same transaction to avoid issues of this sort. I believe I am
following that convention here...but...still getting errors. I have
also tried calling the table1 "Unprepare" and "FreeServerResources"
methods before freeing it but they have not helped in this case.
Can anyone shine some light on what I'm doing wrong ?
Thanks -- Jeff Gaiche
procedure TForm1.Button1Click(Sender: TObject);
var
table1, table2: TIBOTable;
trans: TIB_Transaction;
db: TIBODatabase;
begin
table1:=nil; table2:=nil; db:=nil;
try
db:=TIBODatabase.Create(nil);
db.DatabaseName:='C:\dbs\ne\MIS2000.fdb';
db.Username:='myuser';
db.Password:='mypassword';
try
table1:=TIBOTable.Create(nil);
table1.IB_Connection:=db;
table1.TableName:='COESTUD_D';
table1.Open;
Table1.Insert;
Table1.Fields[0].AsInteger:=1;
Table1.Fields[1].AsInteger:=2;
Table1.Post;
Table1.Close;
finally table1.Free end;
try
table2:=TIBOTable.Create(nil);
table2.IB_Connection:=db;
table2.TableName:='COESTUD_D';
trans:=TIB_Transaction.Create(nil);
trans.IB_Connection:=table2.IB_Connection;
table2.IB_Transaction:=trans;
try
trans.StartTransaction;
table2.AddIndex('MYINDEX','StudentSeq',[]);
trans.Commit; //<-----Exception thrown here
except trans.Rollback; raise end;
finally table2.Free end;
finally db.Free end;
end;
getting a "lock conflict on no wait transaction.....object XXX is in
use" error when I'm trying to add an index to a table. I have a
short contrived example that demonstrates this issue. Basically...I
have a TIBODatabase object that is shared by two TIBOTable objects
which reference the same table in my database. I insert a record
using the first table object and free the object. Then...in a
separate transaction, I attempt to create an index on the same table
using my second TIBOTable object. When I try to commit the
transaction I get the error "lock conflict on no wait transaction
unsuccessful metadata update object XXXXX is in use". If I use an
TIB_Connection object instead of a TIBODatabase object this error
does not occur. As I understand it...we should never mix DDL and DML
in the same transaction to avoid issues of this sort. I believe I am
following that convention here...but...still getting errors. I have
also tried calling the table1 "Unprepare" and "FreeServerResources"
methods before freeing it but they have not helped in this case.
Can anyone shine some light on what I'm doing wrong ?
Thanks -- Jeff Gaiche
procedure TForm1.Button1Click(Sender: TObject);
var
table1, table2: TIBOTable;
trans: TIB_Transaction;
db: TIBODatabase;
begin
table1:=nil; table2:=nil; db:=nil;
try
db:=TIBODatabase.Create(nil);
db.DatabaseName:='C:\dbs\ne\MIS2000.fdb';
db.Username:='myuser';
db.Password:='mypassword';
try
table1:=TIBOTable.Create(nil);
table1.IB_Connection:=db;
table1.TableName:='COESTUD_D';
table1.Open;
Table1.Insert;
Table1.Fields[0].AsInteger:=1;
Table1.Fields[1].AsInteger:=2;
Table1.Post;
Table1.Close;
finally table1.Free end;
try
table2:=TIBOTable.Create(nil);
table2.IB_Connection:=db;
table2.TableName:='COESTUD_D';
trans:=TIB_Transaction.Create(nil);
trans.IB_Connection:=table2.IB_Connection;
table2.IB_Transaction:=trans;
try
trans.StartTransaction;
table2.AddIndex('MYINDEX','StudentSeq',[]);
trans.Commit; //<-----Exception thrown here
except trans.Rollback; raise end;
finally table2.Free end;
finally db.Free end;
end;