Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Exporting a Query...
Sun, Feb 28 2021 8:12 PMPermanent Link

Ian Branch

Avatar

Hi Team,
D10.4.2, current EDB.
I have the following code..
{code}
...
..
 //
 ExportQuery.Export('DBiWStatsExport.csv',  'Exports',  , , , , , , , , , , , , True);
 //
 ExportQuery.Close;
 //
...
....
{code}
I only want to define the file name, Store & Include File Headers.
Unfortunately Delphi doesn't like it as is.
I can add some elements..

{code}
 //
 ExportQuery.Export('DBiWStatsExport.csv', 'Exports', nil, ffDelimited, feAuto, , , , , , , , , , True, -1);
 //
{code}
I would have thought that there was no need to fill in the blanks as they should default??
If I fill in the blanks..
{code}
 //
 ExportQuery.Export('DBiWStatsExport.csv', 'Exports', nil, ffDelimited, feAuto,SEPARATOR, DOUBLE_QUOTE, ANSI_DATE_FORMAT, ANSI_TIME_FORMAT, ANSI_12HOUR_AM, ANSI_12HOUR_PM, ANSI_DECIMAL_SEPARATOR, ANSI_TRUE, ANSI_FALSE, True, -1);
 //
{code}
and have edbcomps in my Uses..
I still get issues with these - SEPARATOR, DOUBLE_QUOTE, ANSI_DATE_FORMAT, ANSI_TIME_FORMAT, ANSI_12HOUR_AM, ANSI_12HOUR_PM, ANSI_DECIMAL_SEPARATOR, ANSI_TRUE, ANSI_FALSE. Frown

I can't find where they are actually defined.

Help...

Regards & TIA,
Ian
Mon, Mar 1 2021 3:07 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


Never having used that I can only try to answer some of your questions. The function is in edbcomps which in my case is located in C:\D2007Ex\ElevateDB\code\source

The constants SEPARATOR, DOUBLE_QUOTE etc MIGHT be in edbstring - look at the uses clause in edbcomps for other possibles

As far as defaults are concerned I have no idea what the official line is but once I've overridden one I supply values for the following ones.

Roy Lambert
Mon, Mar 1 2021 9:53 AMPermanent Link

Raul

Team Elevate Team Elevate

On 2/28/2021 8:12 PM, Ian Branch wrote:

> I only want to define the file name, Store & Include File Headers.
> Unfortunately Delphi doesn't like it as is.

That's not how Delphi works.

> I would have thought that there was no need to fill in the blanks as they should default??

Unfortunately defaults are used only if they are not present - there is
no such thing in delphi as "use default" parameter once you supplyanything.

>    ExportQuery.Export('DBiWStatsExport.csv', 'Exports', nil, ffDelimited, feAuto,SEPARATOR, DOUBLE_QUOTE, ANSI_DATE_FORMAT, ANSI_TIME_FORMAT, ANSI_12HOUR_AM, ANSI_12HOUR_PM, ANSI_DECIMAL_SEPARATOR, ANSI_TRUE, ANSI_FALSE, True, -1);
>    //
> {code}
> and have edbcomps in my Uses..
> I still get issues with these - SEPARATOR, DOUBLE_QUOTE, ANSI_DATE_FORMAT, ANSI_TIME_FORMAT, ANSI_12HOUR_AM, ANSI_12HOUR_PM, ANSI_DECIMAL_SEPARATOR, ANSI_TRUE, ANSI_FALSE. Frown

Those are in edbstring so make sure your uses includes

"edbcomps, edbstring"

if you use this a lot and to keep code clean you could add a class
helper (this is in your code)

i.e.
type
  TEDBQueryHelper = class helper for TEDBQuery
    public
      procedure ExportSimple(
        const ExportFile:string;
        const StoreName: String;
        IncludeHeaders: Boolean);
  end;

implement as

procedure TEDBQueryHelper.ExportSimple(const ExportFile: string;
  const StoreName: String; IncludeHeaders: Boolean);
begin
  Export(
    ExportFile,
    StoreName,
    nil,
    ffDelimited,
    feAuto,
    SEPARATOR,
    DOUBLE_QUOTE,
    ANSI_DATE_FORMAT,
    ANSI_TIME_FORMAT,
    ANSI_12HOUR_AM,
    ANSI_12HOUR_PM,
    ANSI_DECIMAL_SEPARATOR,
    ANSI_TRUE,
    ANSI_FALSE,
    IncludeHeaders);
end;

and then you call it like this using existing code

ExportQuery.ExportSimple('DBiWStatsExport.csv',  'Exports',True);

Raul
Mon, Mar 1 2021 5:10 PMPermanent Link

Ian Branch

Avatar

Tks Raul,
All good now.
No wonder I couldn't find it.  There is no edbstring.pas file. Frown

Regards,
Ian
Image