Subject After Datapump with Delete, DB use leaves ib_transactions nil
Author Chuck Belanger
Hello:

Getting a strange error situation after running some update code on a
user's DB.

Using IBO 4.2+, Delphi 7, WinXP, Local, desktop application.

After running the section of code (just after below), in which I'm using
a Datapump component to delete a large section of a big table, causes a
problem that even when later having all the records inserted back (as an
update), when using the DB I get an AV on the GetStarted Result line. On
checking, the transaction for a number of queries in my program are now
nil, even though set in the properties of the component.

If I use another copy of the DB before apply the DataPump Delete
routine, everything works fine. So it looks like something in this code
messes up the DB in this manner.

There's something about the way I'm doing the DataPump Delete that
leaves the DB unable to keep/use or ? the assigned transaction.

I might add that using the Datapump to do this is about 10x faster than
simply looping through a dataset and applying the delete.

Thank you for any help you can give.

Chuck Belanger

function TIB_Transaction.GetStarted: boolean;
begin
Result := FtrHandle <> nil; ////////////////// AV on this line. A
number of queries in my program now have ib_transaction as nil.
end;


//code which induces problem:


with crUpdate do
begin
//connect is to UpdateTV.fdb
SQL.Clear;

SQL.Add('Select ml_id from MasterLibrary Where ml_owner <> ' +
IntToStr(TV.Owner) );

end; //with crUpdate

with dsqlUpdate do
begin
//connection is to user DB
//can't assume that
ib_transaction := modData.ib_transaction1;

SQL.Clear;
//discovered this to be helpful in Export, especially if dsqlUpdate
//is used in more than one way
Params.ClearBuffers(TIB_RowState(rsNone));

SQL.Add('Delete From MasterLibrary ');
SQL.Add('Where ml_id = :ml_id ')

end;// with dsqlUpdate

DoDataPump(False); //i.e. show the callback

////////////////
procedure TfrmUpdateDlg.DoDataPump(CallBackOff : Boolean);
begin
try
begin
cnIBImport.BeginBusy(true); ////////connect is to UpdateTV.fdb

if CallBackOff then
begin
//no callback at all ; FETCH dlg error with one recrd?
//in this local procedure, single records pumped
crUpdate.OnCallback := nil;
crUpdate.CallbackInc := -1;
//getting an "Invalid Floating Point operation, someplace in
sysfetchall(0)/IBA_Dataset.imp
//Probably having something to do with issue that this datapump in
only
//pumping one record; seems to occur when fetch records dlg pops
up; trying this

//this causes a problem by actually restricting insert, update to
a single rec
// dpUpdate.DstIsSingleton := true;
end
else
begin
//to fix the nagging _Trunc error that occurs when this is called
//with OnCallBack, but only one or maybe 0 records are selected
//I'm checking reccount of the qry first
with crUpdate do
begin
Open;
if RecordCount > 1 then
begin
OnCallback := crUpdateCallback; //routine to move progress bar
CallbackInc := 1;
close;
end
else //make sure no OnCallBack--no point anyway, if only one rec
begin
OnCallback := nil;
CallbackInc := -1;
end;
end;

end;

dpUpdate.DstLinks.Clear;
dpUpdate.DstStatement.Prepared := true;
dpUpdate.SrcDataset.Unprepare;
dpUpdate.SrcDataset.Prepared := true;

dpUpdate.Execute;

//put back to default connection, just in case changed
//This happens in ResetParentID() for a few tables
crUpdate.ib_connection := cnIBImport;

end;
finally
begin
dpUpdate.DstStatement.IB_Transaction.Commit;
cnIBImport.EndBusy;
end;
end;
end;