Field names in stored procedures
Posted in 2004
Topics: Installation, Setup & Upgrades, Stored Procedures & SPL
How do you get the field names to display in the resultset of a stored procedure? In reading the newsgroup articles, it was stated that this feature was going to be part of 9.4. I have just installed 9.4FC3 (HP/UX 11) and executed a stored procedure that had named returns and still got expression,expression instead of the field names. TIA, Randy sending to informix-list
Kennedy, Randy wrote:
> How do you get the field names to display in the resultset of a stored
> procedure? In reading the newsgroup articles, it was stated that this
> feature was going to be part of 9.4. I have just installed 9.4FC3 (HP/UX
> 11) and executed a stored procedure that had named returns and still got
> expression,expression instead of the field names.
To save some typing I'm going to use the same response that I used a week or
so ago when responding to a similar question asked via the Classics list.
In your case, exchange PROCEDURE for FUNCTION. Here is the full response:
A similar subject was discussed recently at comp.databases.informix
(subject: informix 9.4 named columns from stored procedures). Use Google
to see the full thread, but in summary, you would create your procedure in a
manner similar to the following:
CREATE FUNCTION my_proc(in_value INTEGER) RETURNING INTEGER AS my_name;...
END FUNCTION;
Where the integer value returned would be named with 'my_name' rather than
'(expression)'. What we found through testing was that you will have to use
'EXECUTE FUNCTION' to see the results that you are expecting; 'SELECT' will
not do it.
By the way, CREATE PROCEDURE does support a RETURNING clause but Informix
recommends using the CREATE FUNCTION statement, rather than CREATE
PROCEDURE, when your SPL procedure returns one or more values. Just FYI.
--
June Hunt
June C. Hunt wrote: > Kennedy, Randy wrote: > > How do you get the field names to display in the resultset of a stored > > procedure? In reading the newsgroup articles, it was stated that this > > feature was going to be part of 9.4. I have just installed 9.4FC3 (HP/UX > > 11) and executed a stored procedure that had named returns and still got > > expression,expression instead of the field names. > > To save some typing I'm going to use the same response that I used a week or > so ago when responding to a similar question asked via the Classics list. > In your case, exchange PROCEDURE for FUNCTION. Scratch that. If you are returning one or more values, use FUNCTION. > [remainder snipped] -- June Hunt