Re: default values

Поиск
Список
Период
Сортировка
От David Wall
Тема Re: default values
Дата
Msg-id 004801c28e9d$9d951cc0$3201a8c0@expertrade.com
обсуждение исходный текст
Ответ на default values  ("Felipe Schnack" <felipes@ritterdosreis.br>)
Список pgsql-jdbc
> default value of a column using DEFAULT keyword on pgsql 7.3. Example:
>   INSERT INTO TEST (varcharfield1, varcharfield2) VALUES ('text', DEFAULT)
>   In this case, the "varcharfield2" column would get its default value (as
> defined in CREATE TABLE). I was wondering, how I would do it using
> PreparedStatements? If I prepare an SQL like
>   INSERT INTO TEST (varcharfield1, varcharfield2) VALUES (?, ?)
>   I need to have some way to set one of the the parameters as DEFAULT, but
> how? Using the current JDBC driver I believe is impossible, probably we
would
> need something like a "setDefault(int)" method in PreparedStatement, where
int
> is the parameter index. What do you think about it?
>

Why not simply remove varcharfield2 from the INSERT statement and let the
database insert that value with the default value?  Isn't the purpose of a
default value to have the DB put that value in when none is specified?

David


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

Предыдущее
От: Nic Ferrier
Дата:
Сообщение: Re: streaming result sets: progress
Следующее
От: Nic Ferrier
Дата:
Сообщение: Re: streaming result sets: progress