Re: Prepared statements and default values - Mailing list pgsql-jdbc

From Marc Herbert
Subject Re: Prepared statements and default values
Date
Msg-id khju0ccmnmf.fsf@meije.emic.fr
Whole thread Raw
In response to Prepared statements and default values  (Assad Jarrahian <jarraa@gmail.com>)
List pgsql-jdbc
Assad Jarrahian <jarraa@gmail.com> writes:

> thanks for your response David!
>
> Is that the only way, cause that surely does not seem easy when you
> have say 20 columns, of which 15 have default values.
>
> given all the combinations (sometimes this set of column values is
> needed to be default, otherwise another set .... and so on.
>
> Am I stuck with writing out all possible statements ...or is there
> another way?

Move the location of your default values out of the DB into the JDBC
application. Of course your application has to be the only DB user :-(

Else "import" the defaults from the DB into your application.  Insert
into the DB a fake user with defaults for every field and get it back
immediately after; like this you easily "import"/duplicate all the
default values. Clean-up the fake user then systematically
.set(defaults) on all your prepared statements, and re- .set()
them/override them only if the user provided some input.

The issue of course is the duplication/desync of the default values
between the DB and application. How often should they be updated?


My 2 cents.

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Prepared statements and default values
Next
From: "Donald Fraser"
Date:
Subject: 7.4x vs 8.1x