Re: preparedStatement, Batch, DEFAULT, getGeneratedKeys()

Поиск
Список
Период
Сортировка
От dmp
Тема Re: preparedStatement, Batch, DEFAULT, getGeneratedKeys()
Дата
Msg-id 528A5F6A.8030508@ttc-cmc.net
обсуждение исходный текст
Ответ на preparedStatement, Batch, DEFAULT, getGeneratedKeys()  (Martin Eriksson <M.Eriksson@albourne.com>)
Список pgsql-jdbc
Martin Eriksson wrote:
 > 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..
 >
 >    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
 >

Hello Martin,

With regard to 2.

Some databases do allow you to insert default in the prepared statement,
but I have not found that to be the case with PostgreSQL to my knowledge.

Default can be inserted though via the following.

Given:

CREATE TABLE "keY_tAble2" (
   "Host" char(60) NOT NULL default '',
   "Db" char(64) NOT NULL default '',
   "Username" char(16) NOT NULL default '',
   Select_priv boolean NOT NULL default TRUE,
   PRIMARY KEY ("Host","Db","Username")
);

To give the default value to "Host" Use the following prepared statement.

INSERT INTO "public"."keY_tAble2" ("Db", "Username", "select_priv") VALUES (?, ?, ?)

I guess as you said though this does not help with batching.

danap.



В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Martin Eriksson
Дата:
Сообщение: preparedStatement, Batch, DEFAULT, getGeneratedKeys()
Следующее
От: Rahul Ranjan
Дата:
Сообщение: Fwd: postgres join query.