sequence generated keys

Discussion in 'Java' started by Peter Plumber, Jun 8, 2006.

  1. 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
     
    Peter Plumber, Jun 8, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. stef mientki
    Replies:
    13
    Views:
    646
    stef mientki
    Oct 20, 2007
  2. Frank Millman
    Replies:
    0
    Views:
    94
    Frank Millman
    Mar 18, 2013
  3. Chris Angelico
    Replies:
    1
    Views:
    109
    Steven D'Aprano
    Mar 18, 2013
  4. Frank Millman
    Replies:
    0
    Views:
    87
    Frank Millman
    Mar 18, 2013
  5. Peter Otten
    Replies:
    0
    Views:
    108
    Peter Otten
    Mar 18, 2013
Loading...

Share This Page