RE: PostgreSQL sequences revisited

From: Kevin Menard (kmenar..ervprise.com)
Date: Thu Aug 02 2007 - 15:13:43 EDT

  • Next message: Andrus Adamchik: "Re: PostgreSQL sequences revisited"

    > -----Original Message-----
    > From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    > Sent: Thursday, August 02, 2007 8:20 AM
    > To: de..ayenne.apache.org
    > Subject: Re: PostgreSQL sequences revisited
    >
    > A question - would serial type work as an auto-increment? I.e. is it
    > possible to run PreparedStatement like this (notice no PK in the
    > statement):
    >
    > INSERT INTO ARTIST (NAME) VALUES (?)

    This indeed works (no real surprise).

    > And then get back DB-generated ARTIST_ID via
    > java.sql.Statement.getGeneratedKeys()? I suspect no, but if it is, it
    > would be a really nice improvement to PG adapter.

    This does not. The JDBC driver does not support it, per:

    http://gborg.postgresql.org/project/pgjdbc/bugs/bugupdate.php?984
    http://archives.postgresql.org/pgsql-jdbc/2004-09/msg00190.php

    In my quick investigation, it appears the addition of the RETURNING
    clause to DML statements may help push through an implementation of
    getGeneratedKeys(). The RETURNING clause was only recently added in 8.2
    though, so it would not degrade nicely for us.

    We could issue curval() calls, but things could get funky for batched
    INSERTs, I imagine.

    -- 
    Kevin
    



    This archive was generated by hypermail 2.0.0 : Thu Aug 02 2007 - 15:15:10 EDT