Subject Re: [firebird-support] Execute statement
Author Paul Vinkenoog
Hello Martijn,

>> ...shouldn't you place the second apostrophe at the end of the
>> statement to be executed, i.e.
>>
>> execute statement
>> 'select numf1 from my_table where id=1 into :my_numf';

> No, this isn't right. I've taken the below statement from a
> procedure that I used, I had to use it like this, because
>"SUBSTRING" doesn't accept an expressesion/variable, but only
> a constant:
>
> execute statement 'select substring(email from 1 for ' || i || ')
> from gebruiker where gebruikerid = ' || gebruikerid
> into :prefix;

Thanks - I wasn't aware that you could execute a statement INTO
something. But indeed I just found this note in the WhatsNew doc,
under v1.5 beta 4:

* Improved EXECUTE STATEMENT.
Now it's possible to return values from the dynamic SQL.
Syntax:
EXECUTE STATEMENT <value> INTO <var_list>; (singleton form)
or
FOR EXECUTE STATEMENT <value> INTO <var_list> DO <stmt_list>;
Contributor(s):
Alexander Peshkoff <peshkoff at hotmail.ru>


I suppose however that "my" version should work too, because it's
a valid statement. Anyway, it's clear that this isn't the cause
of Sandor's problem, since he's using RC7.


Greetings,
Paul Vinkenoog