Return Field Names from StoredProcedure
Posted in 1999
Topics: Stored Procedures & SPL, Jobs, Consulting & Announcements
We are trying to write dlls which can access any backend stored procedures using ADO, but when your returning a recordset with Informix it returns blank field names, where as the SQL Server returns the field names. Below is out stored procedure for informix CREATE PROCEDURE "informix".cust (custid like customer.customerid) RETURNING char(6), char(30); DEFINE code char(6); DEFINE name char(30); FOREACH SELECT customerid, customername INTO code, name FROM customer WHERE customerid LIKE custid RETURN code, name WITH RESUME; END FOREACH END PROCEDURE;
Hi, we access Informix Dynamic Workgroup Server 7.3 through SP too. I m looking for the same thing, to get the field names, but ist seems there is no change with informix :-( Tschau Manfred >We are trying to write dlls which can access any backend stored procedures >using ADO, but when your returning a recordset with Informix it returns >blank field names, where as the SQL Server returns the field names. Below >is out stored procedure for informix >CREATE PROCEDURE "informix".cust (custid like customer.customerid) > RETURNING char(6), char(30); > DEFINE code char(6); > DEFINE name char(30); > FOREACH SELECT customerid, customername INTO code, name FROM customer >WHERE customerid LIKE custid > RETURN code, name WITH RESUME; > END FOREACH >END PROCEDURE;
For a stored procedure which returns character variables you could simply add a statement at an appropriate point to return column names. In your code below for example, you could do the following DEFINE name char(30); RETURN "Code", "Name" WITH RESUME; FOREACH SELECT customerid, customername INTO code, name FROM customer WHERE customerid LIKE custid But what if you are returning numeric values to a program? How does SQL Server handle that? Rudy On Wed, 1 Sep 1999 13:44:22 +1200, "UKnowWho" <adebaugh@sandfield.co.nz.delete> wrote: >We are trying to write dlls which can access any backend stored procedures >using ADO, but when your returning a recordset with Informix it returns >blank field names, where as the SQL Server returns the field names. Below >is out stored procedure for informix > >CREATE PROCEDURE "informix".cust (custid like customer.customerid) > RETURNING char(6), char(30); > DEFINE code char(6); > DEFINE name char(30); > > FOREACH SELECT customerid, customername INTO code, name FROM customer >WHERE customerid LIKE custid > RETURN code, name WITH RESUME; > END FOREACH > >END PROCEDURE; > > >
Manfred Herr wrote: > > Hi, > > we access Informix Dynamic Workgroup Server 7.3 through SP too. I m looking > for the same thing, to get the field names, but ist seems there is no > change with informix :-( > > Tschau Manfred > > >We are trying to write dlls which can access any backend stored procedures > >using ADO, but when your returning a recordset with Informix it returns > >blank field names, where as the SQL Server returns the field names. Below > >is out stored procedure for informix > > >CREATE PROCEDURE "informix".cust (custid like customer.customerid) > > RETURNING char(6), char(30); > > DEFINE code char(6); > > DEFINE name char(30); > > > FOREACH SELECT customerid, customername INTO code, name FROM customer > >WHERE customerid LIKE custid > > RETURN code, name WITH RESUME; > > END FOREACH > > >END PROCEDURE; Looking at the SP signature, there are no names given for the return values. It's a nuisance. You could decide to assign them arbitrarily - result1, result2, result3, ... But only if the results are going via your own code. They probably aren't, for you. It is a known feature request. I have no idea when or whether it will be implemented. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>