Re: Help! Executing stored procedures produces no output
Posted in 1997
Topics: SQL Development & Query Writing, Stored Procedures & SPL, Server Administration, Platform-Specific Issues
Ian Bishrey wrote:
>
> In Informix SE 7.1 on AIX 4.1.5, using dbaccess...
>
> This may be a dumb question, but can anyone tell me why this produces an
> output:
>
> select * from customer>
> but this does not:
>
> create procedure foo()> {
> select * from customer> }
> end procedure;
> execute procedure foo();>
The procedure is not defined to return anything. The first step is to
CREATE PROCEDURE FOO RETURNING TYPE1, TYPE2...
and at the end of your procedure use a RETURN (VAR1, VAR2...) statement.This will make "EXECUTE PROCEDURE FOO" act like a SELECT statement that
returns one row.
The example select statement in the proc is just local. When it
executes, the results don't get used for anything. You can do a
SELECT..INTO.. into a local variable, and then return the variable, or
better yet, do a foreach, and there is an option to return values, but
keep the current place in the foreach. The Informix documentation has a
good example of this under "Stored Procedures that return more than one
row". Since I don't have the docs handy, and have coded SPs like this
in a long time, I can't be more specific.
Paul.