Re: default values

From: "David Wall" <David(dot)Wall(at)Yozons(dot)com>
To: "Felipe Schnack" <felipes(at)ritterdosreis(dot)br>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: default values
Date: 2002-11-18 00:58:31
Message-ID: 004801c28e9d$9d951cc0$3201a8c0@expertrade.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dror Matalon 2002-11-18 02:06:31 Re: default values
Previous Message Felipe Schnack 2002-11-17 22:30:15 default values