2013-07-22 40 views
1

當然,我想知道調用executeUpdate時有多少行受到影響。 我的executeUpdate調用了插入的存儲過程。我試圖返回和詮釋,但我得到了「返回值過多」即使壽它只是返回一個INTInformix存儲過程和Java executeUpdate

我只是想返回行的數量影響

的Java:

String pro ="{call pro_insert(?,?,?)}"; 
    CallableStatement callableStatement = 
    dbConn.prepareCall(pro); 
    callableStatement.setString(1,"9600111"); 
    callableStatement.setInt(2,1); 
    callableStatement.setInt(3,100);      
    Integer id = callableStatement.executeUpdate(); 

的Informix

CREATE PROCEDURE pro_insert (source varchar(11), request_type_id smallint,result_code_id smallint ) 
    RETURNING int ; 

     INSERT INTO pro_table 
     (
      source,request_type_id,result_code_id,time   
     ) 
     VALUES 
     (
      source,request_type_id,result_code_id,CURRENT 
     ); 

     return dbinfo('sqlca.sqlerrd2'); /* return number of rows affected */    
END PROCEDURE  

回答

1

試試這個

String pro ="{? = call pro_insert(?,?,?)}"; 
CallableStatement callableStatement = dbConn.prepareCall(pro); 
callableStatement.registerOutParameter(1, Types.Integer); 
callableStatement.setString(2,"9600111"); 
callableStatement.setInt(3,1); 
callableStatement.setInt(4,100);      
callableStatement.execute(); 
int res = callableStatement.getInt(1);