If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Java UDF

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-27-09, 08:24
ElenaVas ElenaVas is offline
Registered User
 
Join Date: Nov 2009
Posts: 5
Java UDF

Hello!

My function have only one input parameter(varchar) and should return a table with 3 columns(varchar, varchar, integer).

I have a problem with my function:
"SQL0390N The function "DB2INS79.EMPLOYEES_OF" resolved to specific function "SQL091127145329200" that is not valid in the context where it is used."

I have checked my function, but I didn't find some mistakes..

CREATE FUNCTION EMPLOYEES_OF(DEPTNO VARCHAR(20))
RETURNS TABLE(FIRSTNAME VARCHAR(12),LASTNAME VARCHAR(15),YEARS INTEGER)
LANGUAGE JAVA
EXTERNAL NAME 'TableFunc!outTable'
PARAMETER STYLE DB2GENERAL
.....@



...public class TableFunc extends UDF
{ ...
public void outTable(String Deptno, String FIRSTNAME, String LASTNAME, int Years) throws Exception
{
switch (getCallType())
{ ...
case SQLUDF_TF_FETCH:
if (!rs.next())
{
setSQLstate("02000");
}else{
set(2, rs.getString("FIRSTNME"));
set(3, rs.getString("LASTNAME"));
set(4, rs.getInt("YEARS"));
}
break;
...
}
}

}
Reply With Quote
  #2 (permalink)  
Old 11-27-09, 09:39
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Based on the error message, I suspect the problem is in the way you call this function, not in the function itself.
Reply With Quote
  #3 (permalink)  
Old 11-27-09, 15:03
ElenaVas ElenaVas is offline
Registered User
 
Join Date: Nov 2009
Posts: 5
for example,
I called:
db2 "VALUES(EMPLOYEES_OF('A00'))"

It's wrong...
thanks

Last edited by ElenaVas; 11-27-09 at 16:45.
Reply With Quote
  #4 (permalink)  
Old 11-30-09, 08:40
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You have a table function, which has to be queried like a table:
Code:
SELECT *
FROM TABLE ( employees_of('A00') ) AS t
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On