Results 1 to 4 of 4

Thread: Java UDF

  1. #1
    Join Date
    Nov 2009
    Posts
    5

    Unanswered: 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;
    ...
    }
    }

    }

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Based on the error message, I suspect the problem is in the way you call this function, not in the function itself.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    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 17:45.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •