Reputation: 386
Using dbExpress TSQLQuery, I can't execute a query with execute block command because that command requires ?
notation for parameters, and Delphi uses :
for parameters, then, if in the body of that block creates variables and uses them as
select data from table where .... into :var;
that ":var" is interpreted as a parameter by TSQLQuery.
Which is the way for executing an execute block statement with Delphi?
If I write:
execute block(param1 char(1)=:param1)
I can load a value for :param1 from Delphi, but when I execute it with Query.Open
or Query.ExecSQL
an error returns indicating absence of parameter so ? because in Firebird execute block is written:
execute block(param1 char(1)=?param1)
Is there any way to resolve this with TSQLQuery?
Upvotes: 1
Views: 2354
Reputation: 1
Recently I had a similar issue, but using FDQuery
(Firedac), the solution found was to set the property, ResourceOptions.PreprocessCmdText
of TFQUery
to "False".
Eg.:
qryAux.ResourceOptions.PreprocessCmdText := False;
Upvotes: 0
Reputation: 31
first you can disable the TSQLQuery property for
ParamCheck := False;
Then at the beginning of execute block, remove the parameter path..
execute block (param1 char (1) = :param1)
and your query is passed (%s)
instead of :param1.
I did so in my problem and solved it !
Upvotes: 1
Reputation: 386
the only way that worked for me was not putting ":" for internal vars in the block.
Ex. select data from table into var;
and that's work!, then, as this is a block, evaluate the var with an if!
if (var = 1)
do something;
else
do anotherthing;
and resolved business!
Upvotes: 0
Reputation: 598299
":var" is interpreted as a parameter by TSQLQuery
You can turn that off by setting the ParamCheck
property to False.
Upvotes: 0