我正在使用Delphi(2009年,没关系)与IBX,我正在尝试执行简单的代码:
TestSQL.ExecQuery;
在此代码之前,我已经检查过(并且可以在调试器手表中看到)TestSQL.Transaction.InTransaction
是True
。然而,提出了例外:
EIBInterBaseError with message 'invalid transaction handle (expecting explicit transaction start)'
因此,除了执行代码之外没有其他解决方案:
TestSQL.Transaction.StartTransaction;
TestSQL.ExecQuery;
现在提出了另一个例外:
EIBClientError with message 'Transaction is active'
完全死路一条? Delphi有代码:
procedure TIBTransaction.CheckInTransaction;
begin
if FStreamedActive and (not InTransaction) then
Loaded;
if (FHandle = nil) then
IBError(ibxeNotInTransaction, [nil]);
end;
这意味着交易要求不仅由InTransaction
决定,而且由私人变量FStreamedActive
决定。那么 - 事务控制是否更复杂?我怎么能影响FStreamedActive
?解决办法是什么?我的测试代码是较长代码的一部分,但我想知道如何分解事务状态的内部状态?
我找到了解决方案 - TestSQL.Database
无意中与TestSQL.Transaction.DefaultDatabase
不同。而这表现在如此奇怪的错误信息中。非常奇怪的是,IBX允许所有这些数据库不同。