Home > Software design >  Why Delphi can't find & character within SQLite Select statement?
Why Delphi can't find & character within SQLite Select statement?

Time:04-12

Does anybody have any idea why Delphi 10.4 or 11.1 can't search for the & character within an SQLite SELECT statement in an FMX application? It's being treated like a space character.

I did try the same DB with other platforms, and it works fine, but it doesn't search even in a VCL application either.

I did try using ESCAPE at the end of the query, but nothing changed.

var myQuery      : TFDQuery   ;

myQuery :=TFDQuery.Create(nil);
myQuery.Connection:=FDConnection1;
myQuery.SQL.Text :='SELECT Description,Code,Qty FROM Products WHERE Description LIKE "%J&B%" ';
myQuery.Open;

Please help if anyone can find a solution.

CodePudding user response:

The & has special treatment in FireDAC as can be seen in the documentation: Substitution Variables

To avoid that, set MacroCreate and MacroExpand in ResourceOptions to False.

  • Related