BoBi wrote:
> On Apr 20, 3:23 am, Arne Vajhøj <a...@[EMAIL PROTECTED]
> wrote:
>> Lew wrote:
>>> BoBi wrote:
>>>> ResultSet rs = pstmt.getGeneratedKeys();
>>> If only you were using PostgreSQL, you could use their extension to
the
>>> INSERT command:
>>> [ RETURNING * | output_expression [ AS output_name ] [, ...] ]
>> But since we of course try to write database independent code, then
>> we will not use that even if our current database happen to
>> be PostgreSQL ...
>>
>> The getGeneratedKeys method is database independent - it just require
>> a JDBC 3.0 compliant driver.
Try comparing the Oracle and MSSQL implementations of this supposedly
"database independent" feature. Oracle gets it right and sup****ts
the API: you provide an array of column names in the PrepareStatement(),
and Oracle returns their values for the newly inserted row. MSSQL
throws a SQLException if the array contains more than one element, and
always returns the single "identity" column value regardless of the
column name you specified.


|