Subject Re: Paradox Comparison
Author Aage Johansen
On Sat, 15 Nov 2003 18:29:39 +0000 (UTC), nevillerichards wrote:

> ...
> The original code converted from the Paradox app which imported into the
> Paradox table in 3 minutes is like:
>
> UplifTIBOTable.SetKey;
> UplifTIBOTable.FieldbyName('PostCode').asstring := postcode;
> if not UplifTIBOTable.GotoKey then
> begin
> UplifTIBOTable.append;
> UplifTIBOTable.FieldbyName('PostCode').asstring :=
> postcode;
> end else UplifTIBOTable.edit;
> UplifTIBOTable.FieldbyName('Uplift').asfloat := deprivation;
> UplifTIBOTable.post;
> next;
> // if the record didn't exist, then create it, otherwise, edit what is
> there.
>
>
> The exact same code in the IBO version took approximately 3 hours (I got fed
> up of timing exactly).
> Clearly, this idiom of programming the data transfer which works fine with
> Paradox through TTable is not viable with IBO through TIBOTable.
> There must be a better method, and you have suggested TIB_DSQL, which I need
> to look at.
> Any pointers to how to proceed??


Using a couple of TIB_DSQLs (let's call them dsql_INSERT and dsql_UPDATE):
(Use as starting point, TOTALLY UNTESTED)

with dsql_INSERT do
begin
SQL.Clear;
SQL.Add('insert into UPLIFTI '+
'( POSTCODE, UPLIFT) '+
'values '+
'(:POSTCODE,:UPLIFT)');
Prepare;
end;
with dsql_update do
begin
SQL.Clear;
SQL.Add('update UPLIFTI '+
'set UPLIFT = :UPLIFT '+
'where POSTCODE = :POSTCODE');
Prepare;
end;

PDOXTABLE.Open;
while not PDOXTABLE.Eof do
begin
...
ParamByName('POSTCODE').AsString:=POSTCODE;
ParamByName('UPLIFT' ).AsFloat :=DEPRIVATION;
try
ExecSQL;
except // assume key violation
ParamByName('UPLIFT' ).AsFloat =DEPRIVATION;
ParamByName('POSTCODE').AsString:=POSTCODE;
ExecSQL;
end;
PDOXTABLE.Next;
// do an occasional commit, say every 10000 records
end;
//do a commit here
PDOXTABLE.Close;



--
Aage J.


[Non-text portions of this message have been removed]