Subject | defective datapump program |
---|---|
Author | Duilio Foschi |
Post date | 2002-01-22T01:18:21Z |
using D3 and IBO v. 3.6.Dj, I built my datapump program.
Actually it is a very simple program that uses 2 TIBOTable and 1 TDatabase.
The TIBOTables are SrcTab e DstTab.
SrcTab opens a local DBF e DstTab opens an identical FB table.
For each record in SrcTab, the following code is run (StrLst contains the
field names common to the 2 tables) :
function TForm1.PumpData:boolean;
var
i:integer;
s:string;
begin
result:=True;
try
Database1.StartTransaction;
DstTab.Insert;
for i:=0 to StrLst.Count-1 do
begin
{read field name}
s:=FieldName(StrLst,i);
{copy field value}
DstTab.FieldByName(s).Value:=SrcTab.FieldByName(s).Value;
end;
DstTab.Post;
Database1.Commit;
except
Database1.Rollback; {1}
result:=me_ask('continue ?')=mrOk;
end;
end;
When/if an exception is raised, a Rollback is executed and the user is
prompted to choose btw going ahead (skipping the offending record) or to
stop (the calling routine takes care of stopping the application).
The code works...almost :)
What happen is: after a rollback is done, rollbacks are _always_ done for
all the subsequent - completely potable and innocent - records.
I cannot see the reason for that.
It seems that the exception is not trapped by the try...except...end
statement.
How is that possible ?
Any help ?
Thank you
Duilio Foschi
Actually it is a very simple program that uses 2 TIBOTable and 1 TDatabase.
The TIBOTables are SrcTab e DstTab.
SrcTab opens a local DBF e DstTab opens an identical FB table.
For each record in SrcTab, the following code is run (StrLst contains the
field names common to the 2 tables) :
function TForm1.PumpData:boolean;
var
i:integer;
s:string;
begin
result:=True;
try
Database1.StartTransaction;
DstTab.Insert;
for i:=0 to StrLst.Count-1 do
begin
{read field name}
s:=FieldName(StrLst,i);
{copy field value}
DstTab.FieldByName(s).Value:=SrcTab.FieldByName(s).Value;
end;
DstTab.Post;
Database1.Commit;
except
Database1.Rollback; {1}
result:=me_ask('continue ?')=mrOk;
end;
end;
When/if an exception is raised, a Rollback is executed and the user is
prompted to choose btw going ahead (skipping the offending record) or to
stop (the calling routine takes care of stopping the application).
The code works...almost :)
What happen is: after a rollback is done, rollbacks are _always_ done for
all the subsequent - completely potable and innocent - records.
I cannot see the reason for that.
It seems that the exception is not trapped by the try...except...end
statement.
How is that possible ?
Any help ?
Thank you
Duilio Foschi