Re: default values - Mailing list pgsql-jdbc

From Dave Cramer
Subject Re: default values
Date
Msg-id 1037708769.18319.31.camel@inspiron.cramers
Whole thread Raw
In response to Re: default values  (Felipe Schnack <felipes@ritterdosreis.br>)
List pgsql-jdbc
Felipe,

Ok, for arguments sake, lets say we were to implement it. I'm not saying
we would since it is not part of the jdbc spec, but if we did. How would
it be implemented?

setInt(1, DEFAULT); ?
setDefault(1)?

and then what ? Are you expecting the driver to go and query the db for
the default value?


Dave

On Tue, 2002-11-19 at 07:13, Felipe Schnack wrote:
>   The reasons I don't want to do this are discussed in the message you
> replied.
>   And, again, why not to implement this feature in the driver if the
> database supports it???
>
> On Tue, 2002-11-19 at 10:12, Daniel Serodio wrote:
> > You can pick which column gets the default value by omitting the
> > appropriate field from the INSERT command.
> >
> > eg:
> >
> > CREATE TABLE test (a int default 0, b text default 'foo');
> > INSERT INTO test (a) VALUES (10); -- b gets default value
> > INSERT INTO test (b) VALUES ('bar'); -- a gets default value
> >
> > On Mon, 2002-11-18 at 18:49, Felipe Schnack wrote:
> > >   Yes, and you're not wrong (but I don't consider it right too)
> > >
> > >   1- As I said, my reasons to want that are laziness :-)
> > >   Why? Because I store my inserts in an separated, XML file, so I can't
> > > build sql commands on the fly, adding parameters as required, as many
> > > people do. So, as I am lazy, I want to use the same insert command, but
> > > specify that a specific column should get its default value. Is much
> > > easier than edit a separated file, etc, etc
> > >
> > >   2- This feature is avaliable in pgsql. Why not implement it?
> > >
> > > On Mon, 2002-11-18 at 17:16, Stuart Robinson wrote:
> > > > Hi, Felipe.
> > > >
> > > > I'm been trying to follow the discussion about default values and I'm a little
> > > > confused. I think David's reply is sensible. Unless I'm missing something, I
> > > > don't think there's an issue for inserts. All you have to do is not specify the
> > > > default column in the insert and it will automatically get the default value. I
> > > > think the issue only arises when you do updates, if you want to revert to the
> > > > default for a column that has been changed since it was originally inserted.
> > > >
> > > > Ate mais,
> > > > Stuart
> > > >
> > > > Quoting David Wall <David.Wall@Yozons.com>:
> > > >
> > > > > 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?
> > > >
> > > > --
> > > > Stuart Robinson <stuart@zapata.org>
> > > >
> > > >
> > > > -------------------------------------------------
> > > > This mail sent through IMP: http://horde.org/imp/
> > > --
> > >
> > > Felipe Schnack
> > > Analista de Sistemas
> > > felipes@ritterdosreis.br
> > > Cel.: (51)91287530
> > > Linux Counter #281893
> > >
> > > Faculdade Ritter dos Reis
> > > www.ritterdosreis.br
> > > felipes@ritterdosreis.br
> > > Fone/Fax.: (51)32303328
> > >
> > >
> > > ---------------------------(end of broadcast)---------------------------
> > > TIP 5: Have you checked our extensive FAQ?
> > >
> > > http://www.postgresql.org/users-lounge/docs/faq.html
> > --
> > []'s
> > Daniel Serodio
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Dave Cramer <Dave@micro-automation.net>


pgsql-jdbc by date:

Previous
From: Felipe Schnack
Date:
Subject: Re: default values
Next
From: Alex Dovlecel
Date:
Subject: psql and passwd