Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2004
    Posts
    4

    Angry Unanswered: How to get the RETURN value of the SP in JDBC ?

    Hi All,

    I have a stored procedure that returns a integer value and a ResultSet. How to get the integer value ?
    --------
    - SQL --
    --------
    CREATE PROCEDURE ADMINISTRATOR.test1 ( )
    DYNAMIC RESULT SETS 1
    P1: BEGIN
    DECLARE cursor1 CURSOR WITH RETURN FOR
    SELECT PROCSCHEMA, PROCNAME FROM SYSCAT.PROCEDURES; ---RETURN ResultSet
    OPEN cursor1;
    RETURN 1; --- how to get this value ????????????????
    END P1

    //
    // java code
    //
    Connection con = connectSQL();
    String execRPC = "{call ADMINISTRATOR.test1() }";
    CallableStatement scs = con.prepareCall(execRPC);
    scs.execute();

    // -----------------

    How to get the RETURN value? Pls help.

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    your call needs to look like this:

    //
    // java code
    //
    Connection con = connectSQL();
    String execRPC = "{? = call ADMINISTRATOR.test1() }";
    CallableStatement scs = con.prepareCall(execRPC);

    I believe you need to register it as an out parameter.

    Andy

  3. #3
    Join Date
    Sep 2004
    Posts
    4
    Thank andy!

    it works fine.

    pan_21cn

Posting Permissions

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