From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | Nathan Crause <ncrause(at)uniclear(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: PreparedStatement |
Date: | 2004-09-25 19:33:07 |
Message-ID: | Pine.BSO.4.56.0409251419080.15566@leary.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
On Sat, 25 Sep 2004, Nathan Crause wrote:
> I have a need for the Connection.prepareStatement(String sql, int
> autoGeneratedKeys) method to be functional. Obviously, such keys would
> only ever be generated during an INSERT (as per the Java API
> specification: "This parameter is ignored if the SQL statement is not an
> INSERT statement").
Please see the previous discussion thread starting here:
I know you are just trying to implement something that will make your
existing application work, but we need something that will work for all
situations. There are a number of questions I raise in the thread that no
one has really answered. I know you're looking to avoid the trigger
situation, so let's leave that out for now, but:
How would you return any generated keys for a statement like this:
CREATE TABLE mytable (a serial, b text);
INSERT INTO mytable (b) SELECT (b) FROM mytable;
with multiple rows currval is useless, it can even be useless in the one
row situation (for a pretty contrived case)
CREATE SEQUENCE myseq;
CREATE TABLE mytable (a int default nextval('myseq'), b int default
nextval('myseq'), c text);
INSERT INTO mytable (c) VALUES ('hi');
When writing a library (as opposed to an application) you need to be
prepared to handle all sorts of bizarre situations. At the moment I just
don't think it's possible to make this method work for anything other than
a specific subset of situations.
Kris Jurka
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2004-09-25 19:36:31 | Re: Arrays Question? -Simon Moses |
Previous Message | Nathan Crause | 2004-09-25 17:05:17 | PreparedStatement |