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. Advertisements

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. sandeep Kanwal

    serial keys/validation keys

    sandeep Kanwal, Oct 29, 2004, in forum: C++
    Replies:
    1
    Views:
    724
    Mike Wahler
    Oct 29, 2004
  2. Harry George
    Replies:
    9
    Views:
    917
    sonal
    Jun 13, 2006
  3. Replies:
    10
    Views:
    937
    Daniel T.
    Feb 3, 2006
  4. stef mientki
    Replies:
    13
    Views:
    992
    stef mientki
    Oct 20, 2007
  5. alan
    Replies:
    3
    Views:
    581
    Victor Bazarov
    Nov 28, 2007
  6. A. Farber
    Replies:
    10
    Views:
    420
    A. Farber
    Jun 12, 2004
  7. Frank Millman
    Replies:
    0
    Views:
    173
    Frank Millman
    Mar 18, 2013
  8. Chris Angelico
    Replies:
    1
    Views:
    171
    Steven D'Aprano
    Mar 18, 2013
Loading...