Thread: default values

default values

From
"Felipe Schnack"
Date:
  This is the third time I post this message. Nobody have ANY opinion about
it? I mean, I'm willing to implement a solution for this, but I would like to
discuss a little...
  Someone wrote to pgsql general list telling that you could insert the
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?

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


Re: default values

From
Dror Matalon
Date:
Two ideas:

1. If you don't include the variable in your insert statement, doesn't
the default value happen automatically? In this case
INSERT INTO TEST (varcharfield1) VALUES (?), should result in
varcharfield2 getting its default value.

2. This is a longer shot ...

does  this work?

INSERT INTO TEST (varcharfield1, varcharfield2) VALUES (?, DEFAULT)


Dror



On Sun, Nov 17, 2002 at 09:30:15PM -0100, Felipe Schnack wrote:
>   This is the third time I post this message. Nobody have ANY opinion about
> it? I mean, I'm willing to implement a solution for this, but I would like to
> discuss a little...
>   Someone wrote to pgsql general list telling that you could insert the
> 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?
>
> 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 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Dror Matalon
Zapatec Inc
1700 MLK Way
Berkeley, CA 94709
http://www.zapatec.com

Re: default values

From
Dave Cramer
Date:
1) Yes, it does happen automatically, and to invoke it when it is in the
insert statement, just use setNull

Dave
On Sun, 2002-11-17 at 21:06, Dror Matalon wrote:
> Two ideas:
>
> 1. If you don't include the variable in your insert statement, doesn't
> the default value happen automatically? In this case
> INSERT INTO TEST (varcharfield1) VALUES (?), should result in
> varcharfield2 getting its default value.
>
> 2. This is a longer shot ...
>
> does  this work?
>
> INSERT INTO TEST (varcharfield1, varcharfield2) VALUES (?, DEFAULT)
>
>
> Dror
>
>
>
> On Sun, Nov 17, 2002 at 09:30:15PM -0100, Felipe Schnack wrote:
> >   This is the third time I post this message. Nobody have ANY opinion about
> > it? I mean, I'm willing to implement a solution for this, but I would like to
> > discuss a little...
> >   Someone wrote to pgsql general list telling that you could insert the
> > 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?
> >
> > 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 6: Have you searched our list archives?
> >
> > http://archives.postgresql.org
--
Dave Cramer <Dave@micro-automation.net>


Re: default values

From
Tom Lane
Date:
Dave Cramer <Dave@micro-automation.net> writes:
> 1) Yes, it does happen automatically, and to invoke it when it is in the
> insert statement, just use setNull

Uh ... puh-leez do not tell me that the JDBC driver thinks "null" is
equivalent to "default" ...

            regards, tom lane

Re: default values

From
Dave Cramer
Date:
No, it doesn't, and I am clearly wrong in the statement below

Dave
On Mon, 2002-11-18 at 00:42, Tom Lane wrote:
> Dave Cramer <Dave@micro-automation.net> writes:
> > 1) Yes, it does happen automatically, and to invoke it when it is in the
> > insert statement, just use setNull
>
> Uh ... puh-leez do not tell me that the JDBC driver thinks "null" is
> equivalent to "default" ...
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
--
Dave Cramer <Dave@micro-automation.net>


Re: default values

From
Felipe Schnack
Date:
  Maybe setting null will put the default value in a not null field?
Anyway, in a nullable field null must be inserted.
  I would want to have a setDefault() method for a simple reason
actually... laziness :-)
  The real reason is that in the application i'm working on, we don't
put SQL queries inside java code, it's stored separated, in a XML file.
So if quite boring to type lots of sqls when all you wanted is to omit
the field from the query (we can't build queries using java code).
Anyway, I wasn't so worried about have to type all these commands, but I
heard pgsql have this feature, so would be nice if the driver supports
it.
  What do you think about it? I hear this is a 7.3 new feature.

On Mon, 2002-11-18 at 01:07, Dave Cramer wrote:
> 1) Yes, it does happen automatically, and to invoke it when it is in the
> insert statement, just use setNull
>
> Dave
> On Sun, 2002-11-17 at 21:06, Dror Matalon wrote:
> > Two ideas:
> >
> > 1. If you don't include the variable in your insert statement, doesn't
> > the default value happen automatically? In this case
> > INSERT INTO TEST (varcharfield1) VALUES (?), should result in
> > varcharfield2 getting its default value.
> >
> > 2. This is a longer shot ...
> >
> > does  this work?
> >
> > INSERT INTO TEST (varcharfield1, varcharfield2) VALUES (?, DEFAULT)
> >
> >
> > Dror
> >
> >
> >
> > On Sun, Nov 17, 2002 at 09:30:15PM -0100, Felipe Schnack wrote:
> > >   This is the third time I post this message. Nobody have ANY opinion about
> > > it? I mean, I'm willing to implement a solution for this, but I would like to
> > > discuss a little...
> > >   Someone wrote to pgsql general list telling that you could insert the
> > > 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?
> > >
> > > 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 6: Have you searched our list archives?
> > >
> > > http://archives.postgresql.org
> --
> Dave Cramer <Dave@micro-automation.net>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
--

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


Re: default values

From
"David Wall"
Date:
> 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


Re: default values

From
Felipe Schnack
Date:
  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


Re: default values

From
Daniel Serodio
Date:
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


Re: default values

From
Felipe Schnack
Date:
  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
--

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


Re: default values

From
Dave Cramer
Date:
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>


Re: default values

From
Barry Lind
Date:

Felipe Schnack wrote:
>
>   2- This feature is avaliable in pgsql. Why not implement it?
>
Since default column capability isn't part of the jdbc standard yet (but
since it is part of the SQL standard, I would expect it to be added
someday to the jdbc spec), adding support for it would require the user
to write non-portable jdbc code.  Since there is a portable way to
accomplish the same thing (i.e. not include the column in the insert), I
don't see a compelling reason to add this functionality.

thanks,
--Barry



> 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/
>




Re: default values

From
Felipe Schnack
Date:
  So why setUseServerSidePrepare() was implemented? This is not potable,
not standard, not anything.

On Mon, 2002-11-18 at 22:48, Barry Lind wrote:
>
>
> Felipe Schnack wrote:
> >
> >   2- This feature is avaliable in pgsql. Why not implement it?
> >
> Since default column capability isn't part of the jdbc standard yet (but
> since it is part of the SQL standard, I would expect it to be added
> someday to the jdbc spec), adding support for it would require the user
> to write non-portable jdbc code.  Since there is a portable way to
> accomplish the same thing (i.e. not include the column in the insert), I
> don't see a compelling reason to add this functionality.
>
> thanks,
> --Barry
>
>
>
> > 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


Re: default values

From
Stuart Robinson
Date:
I think Felipe has a point here. I don't see any good reason why the driver's
methods can't be a SUPERSET of those specified in the JDBC standard. As long
as there's nothing forcing you to use the non-standard methods, it should be
fine. So, for those who wish to stick to the standard for portability, there
is predictable behavior; and for those who want some of the extra goodies
provided by Postgres, there are options.

-Stuart

Quoting Felipe Schnack <felipes@ritterdosreis.br>:

>   So why setUseServerSidePrepare() was implemented? This is not potable,
> not standard, not anything.
>
> On Mon, 2002-11-18 at 22:48, Barry Lind wrote:
> >
> >
> > Felipe Schnack wrote:
> > >
> > >   2- This feature is avaliable in pgsql. Why not implement it?
> > >
> > Since default column capability isn't part of the jdbc standard yet (but
> > since it is part of the SQL standard, I would expect it to be added
> > someday to the jdbc spec), adding support for it would require the user
> > to write non-portable jdbc code.  Since there is a portable way to
> > accomplish the same thing (i.e. not include the column in the insert), I
> > don't see a compelling reason to add this functionality.
> >
> > thanks,
> > --Barry
> >
> >
> >
> > > 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 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


--
Stuart Robinson <stuart@zapata.org>


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/

Re: default values

From
Dave Cramer
Date:
Well, the only way this is going to work is if you cast it into a
postgres resultset.

I don't have any particular objection to this extension.

Dave
On Tue, 2002-11-19 at 18:44, Stuart Robinson wrote:
> I think Felipe has a point here. I don't see any good reason why the driver's
> methods can't be a SUPERSET of those specified in the JDBC standard. As long
> as there's nothing forcing you to use the non-standard methods, it should be
> fine. So, for those who wish to stick to the standard for portability, there
> is predictable behavior; and for those who want some of the extra goodies
> provided by Postgres, there are options.
>
> -Stuart
>
> Quoting Felipe Schnack <felipes@ritterdosreis.br>:
>
> >   So why setUseServerSidePrepare() was implemented? This is not potable,
> > not standard, not anything.
> >
> > On Mon, 2002-11-18 at 22:48, Barry Lind wrote:
> > >
> > >
> > > Felipe Schnack wrote:
> > > >
> > > >   2- This feature is avaliable in pgsql. Why not implement it?
> > > >
> > > Since default column capability isn't part of the jdbc standard yet (but
> > > since it is part of the SQL standard, I would expect it to be added
> > > someday to the jdbc spec), adding support for it would require the user
> > > to write non-portable jdbc code.  Since there is a portable way to
> > > accomplish the same thing (i.e. not include the column in the insert), I
> > > don't see a compelling reason to add this functionality.
> > >
> > > thanks,
> > > --Barry
> > >
> > >
> > >
> > > > 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 2: you can get off all lists at once with the unregister command
> >     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> >
>
>
> --
> Stuart Robinson <stuart@zapata.org>
>
>
> -------------------------------------------------
> This mail sent through IMP: http://horde.org/imp/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Dave Cramer <Dave@micro-automation.net>


Re: default values

From
Dror Matalon
Date:
Folks,

This is functionality that's easy to accomplish with the existing
driver, or with minor client side changes. There's little demand for
it so why do we need to change the driver for it?


Dror


On Tue, Nov 19, 2002 at 08:17:25PM -0500, Dave Cramer wrote:
> Well, the only way this is going to work is if you cast it into a
> postgres resultset.
>
> I don't have any particular objection to this extension.
>
> Dave
> On Tue, 2002-11-19 at 18:44, Stuart Robinson wrote:
> > I think Felipe has a point here. I don't see any good reason why the driver's
> > methods can't be a SUPERSET of those specified in the JDBC standard. As long
> > as there's nothing forcing you to use the non-standard methods, it should be
> > fine. So, for those who wish to stick to the standard for portability, there
> > is predictable behavior; and for those who want some of the extra goodies
> > provided by Postgres, there are options.
> >
> > -Stuart
> >
> > Quoting Felipe Schnack <felipes@ritterdosreis.br>:
> >
> > >   So why setUseServerSidePrepare() was implemented? This is not potable,
> > > not standard, not anything.
> > >
> > > On Mon, 2002-11-18 at 22:48, Barry Lind wrote:
> > > >
> > > >
> > > > Felipe Schnack wrote:
> > > > >
> > > > >   2- This feature is avaliable in pgsql. Why not implement it?
> > > > >
> > > > Since default column capability isn't part of the jdbc standard yet (but
> > > > since it is part of the SQL standard, I would expect it to be added
> > > > someday to the jdbc spec), adding support for it would require the user
> > > > to write non-portable jdbc code.  Since there is a portable way to
> > > > accomplish the same thing (i.e. not include the column in the insert), I
> > > > don't see a compelling reason to add this functionality.
> > > >
> > > > thanks,
> > > > --Barry
> > > >
> > > >
> > > >
> > > > > 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 2: you can get off all lists at once with the unregister command
> > >     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> > >
> >
> >
> > --
> > Stuart Robinson <stuart@zapata.org>
> >
> >
> > -------------------------------------------------
> > This mail sent through IMP: http://horde.org/imp/
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> --
> Dave Cramer <Dave@micro-automation.net>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Dror Matalon
Zapatec Inc
1700 MLK Way
Berkeley, CA 94709
http://www.zapatec.com

Re: default values

From
Barry Lind
Date:
Support for server side prepared statements was added in this way
because there is no other easy way to use them in standard jdbc.
However in this case there is an easy way to get default values using
standard jdbc functionality.  I just don't see any compelling reason to
add this extension.

But if you want to add it and provide a patch (and especially test all
the different cases, like server prepared statements, updateable result
sets, callable statements, etc), I would apply the patch, but I don't
plan to spend any time working on this myself.

--Barry


Felipe Schnack wrote:
>   So why setUseServerSidePrepare() was implemented? This is not potable,
> not standard, not anything.
>
> On Mon, 2002-11-18 at 22:48, Barry Lind wrote:
>
>>
>>Felipe Schnack wrote:
>>
>>>  2- This feature is avaliable in pgsql. Why not implement it?
>>>
>>
>>Since default column capability isn't part of the jdbc standard yet (but
>>since it is part of the SQL standard, I would expect it to be added
>>someday to the jdbc spec), adding support for it would require the user
>>to write non-portable jdbc code.  Since there is a portable way to
>>accomplish the same thing (i.e. not include the column in the insert), I
>>don't see a compelling reason to add this functionality.
>>
>>thanks,
>>--Barry
>>
>>
>>
>>
>>>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/
>>>
>>
>>



Re: default values

From
Felipe Schnack
Date:
  That's the idea I suggested a week ago...

On Tue, 2002-11-19 at 23:17, Dave Cramer wrote:
> Well, the only way this is going to work is if you cast it into a
> postgres resultset.
>
> I don't have any particular objection to this extension.
>
> Dave
> On Tue, 2002-11-19 at 18:44, Stuart Robinson wrote:
> > I think Felipe has a point here. I don't see any good reason why the driver's
> > methods can't be a SUPERSET of those specified in the JDBC standard. As long
> > as there's nothing forcing you to use the non-standard methods, it should be
> > fine. So, for those who wish to stick to the standard for portability, there
> > is predictable behavior; and for those who want some of the extra goodies
> > provided by Postgres, there are options.
> >
> > -Stuart
> >
> > Quoting Felipe Schnack <felipes@ritterdosreis.br>:
> >
> > >   So why setUseServerSidePrepare() was implemented? This is not potable,
> > > not standard, not anything.
> > >
> > > On Mon, 2002-11-18 at 22:48, Barry Lind wrote:
> > > >
> > > >
> > > > Felipe Schnack wrote:
> > > > >
> > > > >   2- This feature is avaliable in pgsql. Why not implement it?
> > > > >
> > > > Since default column capability isn't part of the jdbc standard yet (but
> > > > since it is part of the SQL standard, I would expect it to be added
> > > > someday to the jdbc spec), adding support for it would require the user
> > > > to write non-portable jdbc code.  Since there is a portable way to
> > > > accomplish the same thing (i.e. not include the column in the insert), I
> > > > don't see a compelling reason to add this functionality.
> > > >
> > > > thanks,
> > > > --Barry
> > > >
> > > >
> > > >
> > > > > 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 2: you can get off all lists at once with the unregister command
> > >     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> > >
> >
> >
> > --
> > Stuart Robinson <stuart@zapata.org>
> >
> >
> > -------------------------------------------------
> > This mail sent through IMP: http://horde.org/imp/
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> --
> Dave Cramer <Dave@micro-automation.net>
>
--

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


Re: default values

From
Felipe Schnack
Date:
  Well, there was a way to implement server side prepared statements...
All PreparedStatements should be server-side... IMHO the way this is
implemented in pgsql driver is completely non-standard.
  But I don't mind at all, I like the way it is :-)
  Oh, yes, I'm repeating over and over for a week that I would like to
implement it. But I never developed an JDBC driver, much less pgsql
driver... so I would like some pointers. For instance: where I should
implement this? AbstractJdbc3PreparedStatement? How I guaratee this will
be valid only for pgsql 7.3?

On Wed, 2002-11-20 at 02:00, Barry Lind wrote:
> Support for server side prepared statements was added in this way
> because there is no other easy way to use them in standard jdbc.
> However in this case there is an easy way to get default values using
> standard jdbc functionality.  I just don't see any compelling reason to
> add this extension.
>
> But if you want to add it and provide a patch (and especially test all
> the different cases, like server prepared statements, updateable result
> sets, callable statements, etc), I would apply the patch, but I don't
> plan to spend any time working on this myself.
>
> --Barry
>
>
> Felipe Schnack wrote:
> >   So why setUseServerSidePrepare() was implemented? This is not potable,
> > not standard, not anything.
> >
> > On Mon, 2002-11-18 at 22:48, Barry Lind wrote:
> >
> >>
> >>Felipe Schnack wrote:
> >>
> >>>  2- This feature is avaliable in pgsql. Why not implement it?
> >>>
> >>
> >>Since default column capability isn't part of the jdbc standard yet (but
> >>since it is part of the SQL standard, I would expect it to be added
> >>someday to the jdbc spec), adding support for it would require the user
> >>to write non-portable jdbc code.  Since there is a portable way to
> >>accomplish the same thing (i.e. not include the column in the insert), I
> >>don't see a compelling reason to add this functionality.
> >>
> >>thanks,
> >>--Barry
> >>
> >>
> >>
> >>
> >>>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/
> >>>
> >>
> >>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--

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


Re: default values

From
Barry Lind
Date:
Felipe,

To start with you would need to add the method to
org.postgresql.PGStatement interface (that is where the postgresql
specific extensions go).  Then the implementation should go into
org.postgresql.jdbc1.AbstractJdbc1Statement so the method is available
to jdbc1, jdbc2 and jdbc3.  As far as only having it valid for 7.3,
there is a method you can call to check the server version and
conditional do this if the server is 7.3, and probably throw an
exception for an older server, just look through the code for other
instances of code called conditionally based on server version.

The hardest part of this patch (I think) is going to be getting this to
work for updateable result sets.  Also adding all the test cases to the
regression tests will take some time as well.  And don't forget the doc
updates.

thanks,
--Barry



Felipe Schnack wrote:
>   Well, there was a way to implement server side prepared statements...
> All PreparedStatements should be server-side... IMHO the way this is
> implemented in pgsql driver is completely non-standard.
>   But I don't mind at all, I like the way it is :-)
>   Oh, yes, I'm repeating over and over for a week that I would like to
> implement it. But I never developed an JDBC driver, much less pgsql
> driver... so I would like some pointers. For instance: where I should
> implement this? AbstractJdbc3PreparedStatement? How I guaratee this will
> be valid only for pgsql 7.3?
>
> On Wed, 2002-11-20 at 02:00, Barry Lind wrote:
>
>>Support for server side prepared statements was added in this way
>>because there is no other easy way to use them in standard jdbc.
>>However in this case there is an easy way to get default values using
>>standard jdbc functionality.  I just don't see any compelling reason to
>>add this extension.
>>
>>But if you want to add it and provide a patch (and especially test all
>>the different cases, like server prepared statements, updateable result
>>sets, callable statements, etc), I would apply the patch, but I don't
>>plan to spend any time working on this myself.
>>
>>--Barry
>>
>>
>>Felipe Schnack wrote:
>>
>>>  So why setUseServerSidePrepare() was implemented? This is not potable,
>>>not standard, not anything.
>>>
>>>On Mon, 2002-11-18 at 22:48, Barry Lind wrote:
>>>
>>>
>>>>Felipe Schnack wrote:
>>>>
>>>>
>>>>> 2- This feature is avaliable in pgsql. Why not implement it?
>>>>>
>>>>
>>>>Since default column capability isn't part of the jdbc standard yet (but
>>>>since it is part of the SQL standard, I would expect it to be added
>>>>someday to the jdbc spec), adding support for it would require the user
>>>>to write non-portable jdbc code.  Since there is a portable way to
>>>>accomplish the same thing (i.e. not include the column in the insert), I
>>>>don't see a compelling reason to add this functionality.
>>>>
>>>>thanks,
>>>>--Barry
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>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/
>>>>>
>>>>
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>




Re: default values

From
Felipe Schnack
Date:
  Hi folks!
  I'm finishing my effort on implementing DEFAULT keyword on our jdbc
driver!
  I already implemented all features and tested (yes, preparedstatements
and updatable resultsets!) and I just finished test cases...
  1- I just have to add methods to that classes that extend testcase in
order to regression tests run ok, right?
  2- Which docs I should update??

  Thanks in advance!

On Wed, 2002-11-20 at 16:01, Barry Lind wrote:
> Felipe,
>
> To start with you would need to add the method to
> org.postgresql.PGStatement interface (that is where the postgresql
> specific extensions go).  Then the implementation should go into
> org.postgresql.jdbc1.AbstractJdbc1Statement so the method is available
> to jdbc1, jdbc2 and jdbc3.  As far as only having it valid for 7.3,
> there is a method you can call to check the server version and
> conditional do this if the server is 7.3, and probably throw an
> exception for an older server, just look through the code for other
> instances of code called conditionally based on server version.
>
> The hardest part of this patch (I think) is going to be getting this to
> work for updateable result sets.  Also adding all the test cases to the
> regression tests will take some time as well.  And don't forget the doc
> updates.
>
> thanks,
> --Barry
>
>
>
> Felipe Schnack wrote:
> >   Well, there was a way to implement server side prepared statements...
> > All PreparedStatements should be server-side... IMHO the way this is
> > implemented in pgsql driver is completely non-standard.
> >   But I don't mind at all, I like the way it is :-)
> >   Oh, yes, I'm repeating over and over for a week that I would like to
> > implement it. But I never developed an JDBC driver, much less pgsql
> > driver... so I would like some pointers. For instance: where I should
> > implement this? AbstractJdbc3PreparedStatement? How I guaratee this will
> > be valid only for pgsql 7.3?
> >
> > On Wed, 2002-11-20 at 02:00, Barry Lind wrote:
> >
> >>Support for server side prepared statements was added in this way
> >>because there is no other easy way to use them in standard jdbc.
> >>However in this case there is an easy way to get default values using
> >>standard jdbc functionality.  I just don't see any compelling reason to
> >>add this extension.
> >>
> >>But if you want to add it and provide a patch (and especially test all
> >>the different cases, like server prepared statements, updateable result
> >>sets, callable statements, etc), I would apply the patch, but I don't
> >>plan to spend any time working on this myself.
> >>
> >>--Barry
> >>
> >>
> >>Felipe Schnack wrote:
> >>
> >>>  So why setUseServerSidePrepare() was implemented? This is not potable,
> >>>not standard, not anything.
> >>>
> >>>On Mon, 2002-11-18 at 22:48, Barry Lind wrote:
> >>>
> >>>
> >>>>Felipe Schnack wrote:
> >>>>
> >>>>
> >>>>> 2- This feature is avaliable in pgsql. Why not implement it?
> >>>>>
> >>>>
> >>>>Since default column capability isn't part of the jdbc standard yet (but
> >>>>since it is part of the SQL standard, I would expect it to be added
> >>>>someday to the jdbc spec), adding support for it would require the user
> >>>>to write non-portable jdbc code.  Since there is a portable way to
> >>>>accomplish the same thing (i.e. not include the column in the insert), I
> >>>>don't see a compelling reason to add this functionality.
> >>>>
> >>>>thanks,
> >>>>--Barry
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>>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/
> >>>>>
> >>>>
> >>
> >>
> >>---------------------------(end of broadcast)---------------------------
> >>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> >
>
>
>
--

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