在使用 JDBC Batch Insert 语句时,有没有办法使用 JAVA 中的返回子句获取受影响行的值?我能够获得受影响的单行所需的值。但不适用于所有批量插入?
代码 :
try {
String query = "INSERT INTO temp ( "
+ "org_node_id, org_node_category_id, org_node_name, "
+ "customer_id, created_by, created_date_time, "
+ "updated_date_time, activation_Status )"
+ " VALUES (seq_org_node_id.nextval, 11527, 'Abcd', 9756, 1, sysdate, sysdate, 'AC')"
+" returning org_node_id, org_node_name INTO ?, ?";
con = DBUtils.getOASConnection();
OraclePreparedStatement ps = (OraclePreparedStatement) con.prepareStatement(query);
ps.registerReturnParameter(1, Types.INTEGER);
ps.registerReturnParameter(2, Types.VARCHAR);
ps.execute();
ResultSet rs = ps.getReturnResultSet();
rs.next();
System.out.println("Org ID : "+ rs.getInt(1));
System.out.println("Org Name : "+ rs.getString(2));
} catch (SQLException e) {
e.printStackTrace();
}