Is there any way to get the values of affected rows using returning clause in JAVA while using JDBC Batch Insert statement? I am able to get the required values of a single row affected.But not for all Batch Inserts?
Code :
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();
}
rs.next();
must be while(rs.next()) to show all resultset – Nabal