Subject Re: [ib-support] performing a string query
Author Helen Borrie
At 01:10 PM 3/03/2003 +0000, you wrote:
>hello,
>
>I need to execute a string query into a stored procedure like:
>
>execute 'select * from tableName'
>
>or
>
>execute :varstring
>
>where varstring is an input parameter with a truly sql statement.
>
>does anybody know how to perform that ? I am using firebird.

That's not how you create stored procedures. You use CREATE PROCEDURE and
a special set of statement collectively known as PSQL (Programming SQL) to
create compiled code modules. These procedures can be written to take both
input and output arguments; and they can be written in such a way that you
can SELECT from them. You use a FOR...SELECT...DO loop with a SUSPEND
statement at the end of the looping block.

A forthcoming version of Firebird will have an EXECUTE STATEMENT syntax,
that will allow you to pass a SQL statement into a procedure as a string
(varchar), but I don't think you would be able to do a SELECT with it. I
think it would have to be an executable statement, like
UPDATE/INSERT/DELETE/EXECUTE PROCEDURE

heLen