preparedStatement, Batch, DEFAULT, getGeneratedKeys() - Mailing list pgsql-jdbc

From Martin Eriksson
Subject preparedStatement, Batch, DEFAULT, getGeneratedKeys()
Date
Msg-id 6d4e45d3-d470-47b1-b893-b0c8de27ef07@mail-lcy-00.intern.albourne.com
Whole thread Raw
List pgsql-jdbc
Hi,

I've been scourging the mailing list for a while and general google/stack overflow looking for a solution dealing with JDBC, and batching..

  1. appears that there is no way to specific which keys you want to be returned with preparedStatment.getGeneratedKeys() ? I had assumed I could define it as part of the query with "RETURNING column1, column2 but that appear not to work.. its always using RETURNING * which makes it a bit expensive when some columns are like huge blobs.. or will it use the insert values provided and not actually get them sent from the database to client? e.g. if I would do around 100,000 inserts in a batch. The client is far from DB, and one of the fields is a large blob field, would the query return the result to the client with the returning * or are only actually generated keys returned back as data? e.g. 3 fields one timestamp with a now() default, and a big text field, to get at the date field I need to have RETURN_GENERATED_KEYS set, would the large text field be transfered from db to client or would only the timestamp field data be transfered since that is really the only field with "generated keys"?
  2. I've been searching and searching for a way to set "DEFAULT" on a prepared statement, is it even possible? e.g. "INSERT INTO a (id) VALUES (?) and then doing something like prepStatment.setInt(1,"DEFAULT");  I have found no way of doing this... when doing big batches that would be very nice indeed.... to not having to split everything depending on the existence of data in default fields
Cheers
Martin

pgsql-jdbc by date:

Previous
From: Bosco Rama
Date:
Subject: Re: unexpected close
Next
From: dmp
Date:
Subject: Re: preparedStatement, Batch, DEFAULT, getGeneratedKeys()