Subject Re: [firebird-support] weird behaviour [typo corrected]
Author Helen Borrie
At 07:00 PM 7/10/2003 +0000, you wrote:
>I create procedure FOO like:
>
>create procedure FOO(Text varchar(100))
>returns
>(result varchar(100))
>as
>begin
>result=text;
>suspend;
>end !!
>
>I test it with
>
>select * from foo('a' || 'b')
>
>and I get the expected value 'ab'.
>
>Now I redefine procedure FOO like:
>
>create procedure FOO(Text varchar(100))
>returns
>as
>declare variable result varchar(100);
>begin
>result=text;
>end !!
>
>I test it with
>
>execute procedure foo('a' || 'b')
>
>and I get the error message "token unknown ||".
>
>This looks weird to me...

SPs expect constants as input. 'a'||'b' is an expression. If you need to
pass an expression, you'll have to resolve it to a constant in the host
language. What you need to do is prepare the statement with a replaceable
parameter and then have your application pass the resolved expression to
the parameter before executing.
e.g. in Delphi I would do

Sql.clear;
Sql.add(execute procedure foo(:result));
Prepare;
Params[0].AsString := 'a' + 'b';
Execute;

h.