Delete enter character(s) while importing using TUniLoader

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ertank
Posts: 172
Joined: Wed 13 Jan 2016 16:00

Delete enter character(s) while importing using TUniLoader

Post by ertank » Tue 06 Sep 2016 17:47

Hello,

I am using Delphi 10.1.

There is a software package which gets data from barcode scanners. This software is not removing trailing enter characters in barcodes before inserting them in an MSSQL table. There is no way that software producer will implement such a feature in their application. It is not quite possible I talk to all clients and convince them to change their barcode scanner settings so that there will be no enter character at the end of each barcode read.

My application is importing that MSSQL table into a SQLite database table using TUniLoader. I wonder if there is a way to remove them before/during/after importation. What I am searching for is some kind of a SQL statement if it is possible. Either on MSSQL side, or in SQLite side.

Thanks.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Delete enter character(s) while importing using TUniLoader

Post by azyk » Fri 09 Sep 2016 11:56

You can delete leading line breaks from the barcode value, e.g., before loading SQLite data, in the TUniLoader.OnPutData event handler:

Code: Select all

procedure TForm1.UniLoader1PutData(Sender: TDALoader);
var
  Row: integer;
  Barcode : string;
begin
  SQLServerQuery.Open;
  Row := 1;
  while not SQLServerQuery.Eof do begin
    Barcode := SQLServerQuery.FieldByName('barcode').Value;
    // add user code for removing trailing enter characters
    // from Barcode variable value
    ...
    Sender.PutColumnData('barcode', Row, Barcode);
    ...
    SQLServerQuery.Next;
    Inc(Row);
  end;
end;
To start data loading, call the TUniLoader.Load method. See more details about TUniLoader.OnPutData in our online-documentation: https://www.devart.com/unidac/docs/?dev ... utdata.htm

ertank
Posts: 172
Joined: Wed 13 Jan 2016 16:00

Re: Delete enter character(s) while importing using TUniLoader

Post by ertank » Tue 13 Sep 2016 08:32

This approach solves my problem, though Loader performance is affected negatively.

Will try to come up with an alternative solution myself.

Thanks for the example.

Post Reply