× 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.



Hello,

User Defined Table Functions (UDTFs) are available for DB2 UDB for iSeries
from Release V5R2M0 on.
Just have a look at the following redbook:
Stored Procedures, Triggers and User Defined Functions
http://www.redbooks.ibm.com/abstracts/sg246503.html?Open

If you want to return more than one value,
you don't have to specify a table name and don't need to insert values into
this table.
A simple select would be enough.

Example:
CREATE FUNCTION MySchema/GetAdress
      (ParAdrNo Integer)
       RETURNS TABLE
              (FirstName CHARACTER( 15 ) ,
               Name      CHARACTER( 15 ) ,
               ZipCode   DECIMAL  (9, 0) ,
               City      CHARACTER( 15 ))
       LANGUAGE SQL
       NOT DETERMINISTIC
       CONTAINS SQL DATA
       CALLED ON NULL INPUT
       NO EXTERNAL ACTION
       DISALLOW PARALLEL

       RETURN Select  *
                 from MyFile
                Where MyAdrNo = ParAdrNo ;



-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]Im Auftrag von Luqman
Gesendet: Sonntag, 12. Dezember 2004 22:44
An: rpg400-l@xxxxxxxxxxxx
Betreff: DB2 Function to return more than 01 value ?


The following function in Sql Server 2000 returns more than 01 value in the
shape of table.
but the RETURNS TABLE CLAUSE  not working in DB2 Function, is it or similar
supported in DB2 ?

CREATE FUNCTION function2 (principal decimal(12,2),rate
decimal(5,2),startyear int,endyear int)
RETURNS Depreciation  TABLE(
        DEP_YEAR INT NOT NULL,
        Begin_WDV DECIMAL(12,2) NOT NULL,
        Rate DECIMAL(6,3) NOT NULL,
        Dep_Amount DECIMAL(12,2) NOT NULL,
        End_WDV DECIMAL(12,2) NOT NULL)
LANGUAGE SQL
BEGIN
DECLARE variable1 DECIMAL(5,2);
Insert into Depreciation Select * from myTable;
RETURN
END;




Best Regards,

Luqman





--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.