Re: Stored Procedure / ESQL/C question
Posted in 1994
> Jim Gordon (jgordon@ssf-sys.dhl.com) wrote:
> : > Is there any way to make an esql/c program return the column name for
> : > the selected data in the name field of the sqlda structure? I see that
> : > any time I execute a stored procedure which returns back data after a select,
>
> : Currently no. This is partly due to the fact that the engine doesn't
> : really know which attribute in the database a return field from a
> : stored procedure contains. In fact it may not relate to any attribute
> : in the database but may be generated by the stored procedure. I do
>
> Couldn't you put an alias name in the select clause after the expression.
>
> For example:
>
> SELECT a, b+c d FROM table1;>
> returns
>
> a d
> data data
>
> Kristen
Unfortunately we are discussing returns from stored procedures here.
In this situation you might get the following code fragment (Excuse
the syntax as I'm making it up on the fly).
Create procedure test returning char(6), Char(7);
define p_a char(6);
define p_b char(7);
foreach select a, b+c d from table1
into p_a, p_b
return p_a, p_b;
end foreach
end procedure;
The problem with stored procedures is that it is the p_a, p_b
definitions that get returned. These actually come from the returning
part of the create procedure line which have no name so Informix just
defaults the name field to <expression>. This is very bad when you
try to write generalised code that works by name rather than by
position. What I would request is either that names should be
definable in the create procedure line or preferably that the
procedure should pick up the names from the return statement in the
code. The second allows different sets of data to be returned which
external programs can recognise from the difference in the field
names.
Cheers - Jim
My opinions are my own. They may vary with time but they remain MINE!
----------------------------------------------------------------------
Name: Jim Gordon Internet: jgordon@ssf-sys.DHL.COM
Company: DHL Systems Inc Phone: (415) 375-5222 (Work)
Address: 700 Airport Blvd. #300 (415) 775-7762 (Home)
Burlingame, CA 94010-1937 Fax: (415) 375-5019
----------------------------------------------------------------------