Problems with pre-prepared commands in transactions
Posted: Wed 02 Dec 2009 12:25
Hello,
I'm using UniDac 2.70 with firebird 2.1 and have problems with prepared statements in transactions:
There is a master table (tblmaster) with an ID field and a detail table (tbldetail) with an ID+MasterID field and a foreign key MasterID->ID to the master table. In my testapplication are a UniConnection and two UniSQL (insMaster, insDetail) components for inserting data on form.
The following code fails by the insertion of the detail-data:
insDetail.SQL.Text := 'insert into TBLDETAIL(ID, MASTERID) values (:ID, :MASTERID)';
insDetail.Prepared := True;
UniConnection.StartTransaction;
insMaster.SQL.Text := 'insert into TBLMASTER(ID) values (:ID)';
insMaster.Prepared := True;
insMaster.Params[0].AsInteger := 1;
insMaster.Execute;
insDetail.Params[0].AsInteger := 1;
insDetail.Params[1].AsInteger := 1;
insDetail.Execute;
UniConnection.Commit;
It seems, that the prepared insert-command of the detail-table runs not in the transaction. When I prepare this command after the StartTransaction, then it works.
Other situation:
insMaster.SQL.Text := 'insert into TBLMASTER(ID) values (:ID)';
insMaster.Prepared := True;
UniConnection.StartTransaction;
insMaster.Params[0].AsInteger := 1;
insMaster.Execute;
UniConnection.Rollback;
The command is not rolled back because it runs not in the transaction.
Is this problem fixed in version 3 of unidac?
I'm using UniDac 2.70 with firebird 2.1 and have problems with prepared statements in transactions:
There is a master table (tblmaster) with an ID field and a detail table (tbldetail) with an ID+MasterID field and a foreign key MasterID->ID to the master table. In my testapplication are a UniConnection and two UniSQL (insMaster, insDetail) components for inserting data on form.
The following code fails by the insertion of the detail-data:
insDetail.SQL.Text := 'insert into TBLDETAIL(ID, MASTERID) values (:ID, :MASTERID)';
insDetail.Prepared := True;
UniConnection.StartTransaction;
insMaster.SQL.Text := 'insert into TBLMASTER(ID) values (:ID)';
insMaster.Prepared := True;
insMaster.Params[0].AsInteger := 1;
insMaster.Execute;
insDetail.Params[0].AsInteger := 1;
insDetail.Params[1].AsInteger := 1;
insDetail.Execute;
UniConnection.Commit;
It seems, that the prepared insert-command of the detail-table runs not in the transaction. When I prepare this command after the StartTransaction, then it works.
Other situation:
insMaster.SQL.Text := 'insert into TBLMASTER(ID) values (:ID)';
insMaster.Prepared := True;
UniConnection.StartTransaction;
insMaster.Params[0].AsInteger := 1;
insMaster.Execute;
UniConnection.Rollback;
The command is not rolled back because it runs not in the transaction.
Is this problem fixed in version 3 of unidac?