× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi,

a stored procedure has no return value with the exception of result sets.
It's not possible to receive result sets in a Select-Statement.

If you want to retrieve a return value or a table in a SQL-Select-Statement
as you specified, you either have to create a User Defined Function (UDF) or
a User Defined Table Function (UDTF)

Example:
Create Function MySchema/MyUDF(ParmItemNo Integer)          
       Returns VarChar(50)                                     
       Language SQL                                         
       Deterministic                                        
       Reads    SQL DATA                                    
       Returns NULL on NULL Input                           
       DisAllow PARALLEL                                    
       Return (Select ItemDesc from MyTable where ItemNo = ParmItemNo)
;

An UDF can be used as follows:
select itemnum as ItemNum, MyUDF(itemNum) as ItemDescription
from db2table

An UDTF can be used as follows:
Select Fld1, Fld2 .... FldN
>From table(MyUDTF(Parm1, Parm2, ... ParmN)) as MyTable

Birgitta

"If you think education is expensive, try ignorance"
(Derek Bok)
 
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von DebbieKelemen
Gesendet: Mittwoch, 22. März 2006 23:57
An: 'Midrange Systems Technical Discussion'
Betreff: SQL Select Statement in a Stored Procedure Question

All right....I know I should have the web developer join the list & ask this
question, but here goes again......

We want to do a select statement encapsulated in a stored procedure which
returns a result set to a calling program.  Nested inside the stored proc we
want to call another stored proc within a select statement.
 
Such as......
 
select itemnum as ItemNum
(call storedprocedure(itemnum) as ItemDescription
from db2table

Is there a way to do this?

Any help would be greatly appreciated.

Debbie Kelemen
Sr. Programmer / Analyst
Chef's Catalog
(719) 272-2617
dkelemen@xxxxxxxxxxxxxxxx



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.