0
votes

I Have the following array that holds the lines of a SQL statement:

  SQLQueryLines : array [00..04] of string = 
      ('select   "Costumer"."Name", ',
                '"Costumer"."Age", ',
                '"Costumer"."Gender" '
       'from     "Costumer" '
       'where    "Costumer"."Name" = :aCostumerName');

At runtime, I do the following assignment:

  Query.SQL.Add (SQLQueryLines [0]);
  Query.SQL.Add (SQLQueryLines [1]);
  Query.SQL.Add (SQLQueryLines [2]);
  Query.SQL.Add (SQLQueryLines [3]);
  Query.SQL.Add (SQLQueryLines [4]);

but FireDAC fails to recognize the parameter "aCostumerName".

However, it recognizes the parameter if I make the assignment directly:

      Query.SQL.Add ('select   "Costumer"."Name", ');
      Query.SQL.Add (         '"Costumer"."Age", ',);
      Query.SQL.Add (         '"Costumer"."Gender" ');
      Query.SQL.Add ( 'from    "Costumer" ');
      Query.SQL.Add ( 'where   "Costumer"."Name" = :aCostumerName');

Query is a TFDQuery.

I can't figure out why FireDAC should handle differently the above assignments and I didn't find any help searching the Web. Anyone has the answer for this issue?. Thanks

1

1 Answers

0
votes

There is no difference between filling string list collection from string array and by constants. But your second posted code won't even compile (because of the last comma at the second line). So try to make sure you haven't modified your query in your real code somehow.

Btw. you can simplify filling that collection with a loop:

var
  Line: string;
begin
  for Line in SQLQueryLines do
    Query.SQL.Add(Line);
end;

Or in older Delphi like:

var
  Index: Integer;
begin
  for Index := Low(SQLQueryLines) to High(SQLQueryLines) do
    Query.SQL.Add(SQLQueryLines[Index]);
end;