1

自然我想知道当我调用executeUpdate 时有多少行受到影响。我的 executeUpdate 调用一个执行插入的存储过程。我试图返回和 int,但我得到“返回太多值”,即使它只是返回一个 int

我只是想返回受影响的行数

爪哇:

    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    
4

1 回答 1

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);
于 2013-07-22T15:01:16.583 回答