I have a project in Spring MVC, I'm using getJdbcTemplate
to do insert's.
I just do not enter the primary key in Oracle from a sequence and need that value to re-insert into another table where that value is a foreign key.
For example:
insert into tableS(SEQ, dateX, ab, flag) values(SEQ_table.nextval, ?, ?, 'N')
And I'm using getJdbcTemplate
to insert from Spring, but I need the value of the java-side SEQ to insert into the following table with the value in foreign key.
getJdbcTemplate().batchUpdate(INSERT_TABLE, new BatchPreparedStatementSetter() {
public void setValues(PreparedStatement ps, int i) throws SQLException {
String valor= info.getvalues().get(i);
ps.setString(1, valor.geta());
ps.setLong(2, valor.getb());
}
public int getBatchSize() {
return info.getvalues().size();
}
});
Any ideas how to solve this problem?