UniLoader error trapping?
Posted: Fri 31 Jan 2014 00:19
I am having problems trying to get the UniLoader component to work in D7. The Help and Demos are extremely limited.
I can get UniLoader to work importing records into a MSSQL database if the destination table is empty. I cannot do it if there are any records in the table. I do not think it has anything to do with duplicate keys or anything like that. I go to some effort to delete any possible conflicts before I do the Load. The problem is it is hard to tell...there does not seem to be any error trapping at all. This is the crux of my question - how can I error trap UniLoader?
This is what I am doing
I open a UniQuery (qryFastLoad) with the records that I want to import into the destination table. Some 20,000 records in my example. If the destination table is empty, no problems (also very fast! Most impressive).
If there are records in the table, a few records are loaded - then it basically freezes. Nothing happens - the program gets into a loop and the process has to be killed.
This is my Put procedure. There is a Primary key on the fields ID,TILLID.
I can get UniLoader to work importing records into a MSSQL database if the destination table is empty. I cannot do it if there are any records in the table. I do not think it has anything to do with duplicate keys or anything like that. I go to some effort to delete any possible conflicts before I do the Load. The problem is it is hard to tell...there does not seem to be any error trapping at all. This is the crux of my question - how can I error trap UniLoader?
This is what I am doing
Code: Select all
UniLoader1.Connection := Master.iConnectUNI;
UniLoader1.tablename := xxTablename;
UniLoader1.CreateColumns;
UniLoader1.OnPutData := PutColumnData;If there are records in the table, a few records are loaded - then it basically freezes. Nothing happens - the program gets into a loop and the process has to be killed.
This is my Put procedure. There is a Primary key on the fields ID,TILLID.
Code: Select all
procedure TfrmSendToRegisters.PutColumnData(Sender: TDALoader); var
i: integer;
begin
i := 0;
if qryFastLoad.recordcount > 0 then
begin
ProgressBar2.MaxValue := qryFastLoad.recordcount;
while (not qryFastLoad.EOF) do
begin
inc(i);
try
ProgressBar2.UserValue := i;
Sender.PutColumnData('ID', i, qryFastLoad.FieldByName('ITEMID').AsString);
Sender.PutColumnData('TillID', i, qryFastLoad.FieldByName('TILL_NUMBER').AsString);
Sender.PutColumnData('COST', i, qryFastLoad.FieldByName('UNITCOST').AsFloat);
Sender.PutColumnData('SELL', i, qryFastLoad.FieldByName('PRICE1').AsFloat);
Sender.PutColumnData('INSTRUCTIONSID', i, qryFastLoad.FieldByName('INSTRUCTION').AsString);
Sender.PutColumnData('ENABLED', i, qryFastLoad.FieldByName('ENABLED').AsString);
qryFastLoad.next;
except
on e: exception do
begin
showmessage('Put Column Error ' + e.message);
end;
end;
end;
end;
end;