Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: FDBatchMove doubling double quotes in output


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 6 - Last Post: Apr 28, 2017 10:34 AM Last Post By: Douglas Corey
Douglas Corey

Posts: 4
Registered: 5/21/17
FDBatchMove doubling double quotes in output  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 21, 2017 11:59 AM
I am trying to use FireDAC components to replace BCP, using TFDBatchMove, TFDBatchMoveDataSetReader, TFDBatchMoveTextWriter, and TFDQuery, to output to a fixed column text file. If the data contains a double quote ("), then the output file will contain double double quotes (""):

ISACC "IKE" HOLLIS
becomes:
ISACC ""IKE"" HOLLIS

the code that I am using is like this:

FDQuery1.SQL.Text := 'Select * from NameTable'
with TFDBatchMoveDataSetReader.Create(FDBatchMove1) do begin
DataSet := FDQuery1;
Optimise := False;
end;
with TFDBatchMoveTextWriter.Create(FDBatchMove1) do
begin
FileName := 'OutFile.txt';
Datadef.RecordFormat := rfFixedLength;
end;

If I pass the sql text to a sqlcmd, then returned text is correct, without the double double quotes.

Aside from setting the Connection, I have not made any changes to the component defaults.

What do I need to do, to get the data returned without doubling the double quotes?

Edited by: Douglas Corey on Apr 21, 2017 12:00 PM

Maxime Bonin

Posts: 61
Registered: 1/23/17
Re: FDBatchMove doubling double quotes in output  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 21, 2017 2:32 PM   in response to: Douglas Corey in response to: Douglas Corey
Have you tried setting the encoding on the TFDBatchMoveTextWriter ? http://docwiki.embarcadero.com/Libraries/Seattle/en/FireDAC.Comp.BatchMove.Text.TFDBatchMoveTextDriver.Encoding
(I don't have Delphi at home, so I haven't tested it)

Edited by: Maxime Bonin on Apr 21, 2017 2:45 PM
Douglas Corey

Posts: 4
Registered: 5/21/17
Re: FDBatchMove doubling double quotes in output  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 25, 2017 9:15 AM   in response to: Maxime Bonin in response to: Maxime Bonin
Maxime Bonin wrote:
Have you tried setting the encoding on the TFDBatchMoveTextWriter ? http://docwiki.embarcadero.com/Libraries/Seattle/en/FireDAC.Comp.BatchMove.Text.TFDBatchMoveTextDriver.Encoding
(I don't have Delphi at home, so I haven't tested it)

Edited by: Maxime Bonin on Apr 21, 2017 2:45 PM

I have tried all four options: ecDefault, ecAnsi, ecUTF8, and ecUTF16. No change.
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: FDBatchMove doubling double quotes in output  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 27, 2017 1:02 AM   in response to: Douglas Corey in response to: Douglas Corey
If you have FireDAC sources, then do:
* open FireDAC.Comp.BatchMove.Text.pas
* go to line 1058 (TFDTextDataDef.SetRecordFormat method, rfFixedLength case)
* replace line:
        FDelimiter := #34;

with:
        FDelimiter := #0;

* add FireDAC sources to IDE Library Path

--
With best regards,
Dmitry
Douglas Corey

Posts: 4
Registered: 5/21/17
Re: FDBatchMove doubling double quotes in output  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 28, 2017 10:34 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
If you have FireDAC sources, then do:
* open FireDAC.Comp.BatchMove.Text.pas
* go to line 1058 (TFDTextDataDef.SetRecordFormat method, rfFixedLength case)
* replace line:
        FDelimiter := #34;

with:
        FDelimiter := #0;

* add FireDAC sources to IDE Library Path

--
With best regards,
Dmitry

So this is a bug, then, since for fixed length, there should be no delimiter, and if you change it, then it changes RecordFormat to rfCustom. This fixes it, and alternatively, instead of changing the FireDAC code, I could create a class that inherits from this, and override SetSeparator.
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: FDBatchMove doubling double quotes in output  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 22, 2017 10:53 PM   in response to: Douglas Corey in response to: Douglas Corey
TFDBatchMoveTextWriter doubles delimiter character. So, set TFDBatchMoveTextWriter.DataDef.Delimiter to #0.

--
With best regards,
Dmitry
Douglas Corey

Posts: 4
Registered: 5/21/17
Re: FDBatchMove doubling double quotes in output  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 25, 2017 8:55 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Dmitry Arefiev wrote:
TFDBatchMoveTextWriter doubles delimiter character. So, set TFDBatchMoveTextWriter.DataDef.Delimiter to #0.

--
With best regards,
Dmitry

Setting Delimiter to #0 overrides my setting RecordFormat to rfFixedLength. The data comes out ; delimited
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02