From: | Sven Köhler <skoehler(at)upb(dot)de> |
---|---|
To: | pg(at)fastcrypt(dot)com |
Cc: | "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: getGeneratedKeys method |
Date: | 2005-02-19 17:40:58 |
Message-ID: | 42177A2A.5000304@upb.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
> 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!
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2005-02-19 19:27:25 | Re: DatabaseMetaData.getIndexInfo and function-based indexes |
Previous Message | Sven Köhler | 2005-02-19 17:15:54 | How to get generated primary key? |