sequence generated keys

P

Peter Plumber

String sql = "INSERT INTO parameters" +
" (id, task_id, element_identifier," +
" element_property, property_value) " +
" VALUES ( nextval('parameters_id_seq'::regclass)" +
", '" + taskID + "', 'this', '" + parameterName +
"', '" + parameterValue + "')";

// the INSERT succeeds (PostgreSQL 8.1.1)
Statement st = connect();
st.executeUpdate(sql);
st.getConnection().close();

// but I would like to retrieve the new ID value
// created by the SEQUENCE-Function
// error description: Returning autogenerated keys is not supported.
Statement st = connect();
st.execute(sql, Statement.RETURN_GENERATED_KEYS);
ResultSet insertedKeys = st.getGeneratedKeys();
st.getConnection().close();

Any ideas how to get around this problem
is there a jdbc way to do this

thanx

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top