From: Ken Johanson <pg-user@kensystem.com>
To: pgsql-jdbc@postgresql.org
Cc: Michael Paesold <mpaesold@gmx.at>
Subject: Re: Synthesize support for Statement.getGeneratedKeys()?
Date: Fri, 19 Jan 2007 22:59:30 -0700
Message-ID: <45B1AFC2.5060900@kensystem.com> (raw)
In-Reply-To: <45B1AC19.3090300@kensystem.com>
References: <4580E681.3080106@kensystem.com>
<45810230.80803@gmx.at>
<45B1AC19.3090300@kensystem.com>
>
> If someone has pointers to where the augmentaion code should be placed
> (org.tgresql.jdbc3.Jdbc3ResultSetMetadata I presume), and also the
> protocol (separate query to the server?, or append RETURNING clause to
> the DML?).
>
> Also I cant remember - is it true that when inserting multuple VALUES,
> that only the first (or last) SEQUENCE can be retrived, or can I
> populate a resultset using the RETURNING data from by the server?
>
Answering my own question here... sort of :)
http://www.postgresql.org/docs/current/static/sql-insert.html
In the case of inserting multiple values (say 3 rows), is there a clever
way to get the last 3 sequences via native SQL? Or would the JDBC code
need to synthesize them?: (very simplified)
...exec
rs.next();//single key returned
Object id = rs.getObject();
Object[] keys = new Object[insertedRowCount];
for (; keys.length; i++)
keys[i] = increment(id);
myPGResultSet.populate(userDeclaredKeyNameOrIdx, keys);//hypothetical -
i didn't look at the API yet, sorry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: pg-user@kensystem.com, mpaesold@gmx.at
Subject: Re: Synthesize support for Statement.getGeneratedKeys()?
In-Reply-To: <45B1AFC2.5060900@kensystem.com>
References: <4580E681.3080106@kensystem.com> <45810230.80803@gmx.at> <45B1AC19.3090300@kensystem.com> <45B1AFC2.5060900@kensystem.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox