Advertisement

05.29.2008 at 02:57PM PDT, ID: 23443111
[x]
Attachment Details

Function that returns a table on iSeries V5R4 DB2

Asked by ccshooltz in DB2 Database, Programming for iSeries / AS400, AS / 400

Tags: DB2 on iSeries V5R4

I'm a T-SQL guy and I'm trying to write a function that returns a table in DB2 (on our iSeries V5R4).  
I can create the function but I can't select from it.  Attached is the DDL I am using.  This is a very simple example using IBM supplied objects just to show my point.  

I just don't understand why I can't select from the function.  When I try I get the following error.  


SQL State: 42704
Vendor Code: -204
Message: [SQL0204] TESTFUNC in *LIBL type *N not found. Cause . . . . . :   TESTFUNC in *LIBL type *N was not found. If the member name is *ALL, the table is not partitioned. If this is an ALTER TABLE statement and the type is *N, a constraint or partition was not found. If this is not an ALTER TABLE statement and the type is *N, a function, procedure, trigger or sequence object was not found. If a function was not found, TESTFUNC is the service program that contains the function.  The function will not be found unless the external name and usage name match exactly.  Examine the job log for a message that gives more details on which function name is being searched for and the name that did not match. Recovery  . . . :   Change the name and try the request again.  If the object is a node group, ensure that the DB2 Multisystem product is installed on your system and create a nodegroup with the CRTNODGRP CL command. If an external function was not found, be sure that the case of the EXTERNAL NAME on the CREATE FUNCTION statement exactly matches the case of the name exported by the service program.


Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
SET PATH='MYSCHEMA';
SET SCHEMA='MYSCHEMA';
 
CREATE FUNCTION TESTFUNC(P_VALUE CHAR(1)) 
  RETURNS TABLE (IBMREQD CHAR(1)) 
  LANGUAGE SQL 
  DISALLOW PARALLEL
Begin
   RETURN SELECT IBMREQD  FROM SYSIBM.SYSDUMMY1 where IBMREQD=P_VALUE ;
END
;
 
 
SELECT * FROM TABLE(TESTFUNC('Y')) as X;
[+][-]05.29.2008 at 03:26PM PDT, ID: 21673867

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: DB2 Database, Programming for iSeries / AS400, AS / 400
Tags: DB2 on iSeries V5R4
Sign Up Now!
Solution Provided By: daveslash
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.29.2008 at 05:32PM PDT, ID: 21674445

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628