From: Sven Köhler <skoehler@upb.de>
To: pg@fastcrypt.com
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: getGeneratedKeys method
Date: Sat, 19 Feb 2005 18:40:58 +0100
Message-ID: <42177A2A.5000304@upb.de> (raw)
In-Reply-To: <1085573511.1654.20.camel@localhost.localdomain>
References: <20040526115632.87009.qmail@web51008.mail.yahoo.com>
<1085573511.1654.20.camel@localhost.localdomain>
> Yes, this is correct, there is no functionality in postgres to get the
> generated keys.
That's sad.
> This is because the keys are generated using a sequence which can be any
> of the columns in the row, there is no apriori knowledge of the column
> that is being generated.
First, we have to define what a "generated key" is! If you define it as
a value generated by a sequence, than this is hard to find out.
Simply take the following definition:
A column in the primary key is a "generated key", iff a value for the
columns hasn't been given in the INSERT and if the column has a default
value.
With this definition, is should be easy for the server to find the
generated keys.
> 2) get the key after the insert leaving the key value out of the insert,
> or inserting a null there. select currval('sequence_name');
but you have to know the sequence name for that. That's really bad!
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: skoehler@upb.de, pg@fastcrypt.com
Subject: Re: getGeneratedKeys method
In-Reply-To: <42177A2A.5000304@upb.de>
References: <20040526115632.87009.qmail@web51008.mail.yahoo.com> <1085573511.1654.20.camel@localhost.localdomain> <42177A2A.5000304@upb.de>
* 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