Skip site navigation (1) Skip section navigation (2)

Re: Retrieve auto-generated key.

From: Alexander Panzhin <jalexoids(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Retrieve auto-generated key.
Date: 2008-11-04 22:42:23
Message-ID: 4910CFCF.10703@gmail.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
If you want an easy solution(and a bit more portable), you probably are 
better off with doing a "SELECT lastval()"
Though an insert trigger inserting into another table with a serial 
column might screw up the result.

See http://www.postgresql.org/docs/8.3/interactive/functions-sequence.html


> Hi
>
>  
>
> Ability to retrieve auto-generated key is one of the key features of 
> JDBC3.
> I tried using prepareStatement(String sql, int autoGeneratedKeys) , 
> prepareStatement(String sql, int[] columnIndexes) and 
> prepareStatement(String sql, String[] columnNames) but with no success 
> . It returned with exception message as "Returning autogenerated keys 
> is not supported."
>
>  
>
> I know there is already one thread for retrieve auto-generated key but 
> look like that thread does not have one distinct   solution.
>
> Is there any patch or workaround to retrieve auto-generated key ?
>
>  
>
>  
>
> Thanks
>
> Sangeeta
>

In response to

pgsql-jdbc by date

Next:From: Christophe JantonDate: 2008-11-05 14:59:05
Subject: Bug report (with solution) on org.postgresql.jdbc2.EscapedFunctions
Previous:From: gcjDate: 2008-11-04 21:49:46
Subject: Re: Retrieve auto-generated key.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group