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 > How to get the RETURN value of the SP in JDBC ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-01-04, 11:11
pan_21cn pan_21cn is offline
Registered User
 
Join Date: Sep 2004
Posts: 4
Angry 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.
Reply With Quote
  #2 (permalink)  
Old 09-01-04, 12:26
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
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
Reply With Quote
  #3 (permalink)  
Old 09-02-04, 01:46
pan_21cn pan_21cn is offline
Registered User
 
Join Date: Sep 2004
Posts: 4
Thank andy!

it works fine.

pan_21cn
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