A TFDQuery with PostgreSQL fails to execute when I have parameters in the query. The error message is: [FireDAC][Phys][PG][libpq] ERROR: syntax error at or near ":"
ParamByName executes but PostgreSQL sees the ":" and the exception occurs in ExecSQL. This seems to indicate there is an issue with FireDAC setting the parameter.
Although I could manually work around the issue by substituting the parameters in the SQL at runtime, I would prefer this to work as it does in other databases.
Code
try
v_Step := 'SetParameter';
FDQuery3.ParamByName('increment').AsInteger := 100;
v_Step := 'ExecSQL';
FDQuery3.ExecSQL;
except
on E: Exception do
begin
Memo1.Lines.Add(v_Step+': '+E.Message);
Memo1.Lines.Add(FDQuery3.SQL.Text);
end;
end;
Memo1.Text
ExecSQL: [FireDAC][Phys][PG][libpq] ERROR: syntax error at or near ":"
do $$
begin
update mytable set testno = testno+:increment where id = 1;
commit;
end
$$