pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marc Herbert <Marc.Herbert@continuent.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Prepared statements and default values
Date: Tue, 10 Jan 2006 10:35:36 +0100
Message-ID: <khju0ccmnmf.fsf@meije.emic.fr> (raw)
References: <4bd3e1480601091924q54cfee5cs1c6744638e650fff@mail.gmail.com>
	<43C32A5D.8020807@computer.org>
	<4bd3e1480601092002m7f637397nef9654c5014f4785@mail.gmail.com>

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.




view thread (5+ messages)

Message-ID: <khju0ccmnmf.fsf@meije.emic.fr>
Permalink:  ../khju0ccmnmf.fsf@meije.emic.fr/
Also on:    postgresql.org/message-id/khju0ccmnmf.fsf@meije.emic.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: Marc.Herbert@continuent.com
  Subject: Re: Prepared statements and default values
  In-Reply-To: <khju0ccmnmf.fsf@meije.emic.fr>
  References: <4bd3e1480601091924q54cfee5cs1c6744638e650fff@mail.gmail.com> <43C32A5D.8020807@computer.org> <4bd3e1480601092002m7f637397nef9654c5014f4785@mail.gmail.com> <khju0ccmnmf.fsf@meije.emic.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox