Subject Re: [ib-support] calling stored procedure from embedded sql
Author Helen Borrie
At 12:27 PM 11/06/2003 +0000, you wrote:
>How is it done?
>
>I attempt the following call:
>
>EXEC SQL EXECUTE PROCEDURE FOO;
>
>(Actually DB1.FOO because the procompiler complains that FOO is
>ambiguous.)
>
>The statement precompiles and compiles, but bombs on execution.

AFAIK, you can't call a DSQL statement directly like this in ESQL.

You need to 1) declare a host variable for the statement
EXEC SQL DECLARE exec_foo STATEMENT;
2) prepare the statement (apply the string to the host variable)
EXEC SQL PREPARE exec_foo FROM 'EXECUTE PROCEDURE FOO';
3) if the procedure returns any output, describe it:
EXEC SQL DESCRIBE OUTPUT exec_foo USING DESCRIPTOR xsqlda;
4) finally execute the statement:
EXEC SQL exec_foo USING DESCRIPTOR xsqlda;

There's more to it, if you have input and output parameters, with or
without host variables declared to store/receive them.

This isn't the advice of an experienced ESQL programmer, btw. I got this
from the manual. At least if it's wrong, you will get 10,000 ESQL
programmers setting the record straight for you. :-))

Would you please stop cross-posting your support questions to
ib-conversions? That list is for issues about converting other databases
to Firebird or InterBase...

^heLen