X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id B60E29DC809 for ; Tue, 10 Jan 2006 06:00:53 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56489-05 for ; Tue, 10 Jan 2006 06:00:55 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 659FA9DC81E for ; Tue, 10 Jan 2006 06:00:51 -0400 (AST) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by svr4.postgresql.org (Postfix) with ESMTP id D55A75AF04B for ; Tue, 10 Jan 2006 10:00:53 +0000 (GMT) Received: from root by ciao.gmane.org with local (Exim 4.43) id 1EwGJ0-0006s7-1B for pgsql-jdbc@postgresql.org; Tue, 10 Jan 2006 11:00:42 +0100 Received: from 83.145.96.118 ([83.145.96.118]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 Jan 2006 11:00:42 +0100 Received: from Marc.Herbert by 83.145.96.118 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 Jan 2006 11:00:42 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Marc Herbert Subject: Re: Prepared statements and default values Date: Tue, 10 Jan 2006 10:35:36 +0100 Lines: 28 Message-ID: References: <4bd3e1480601091924q54cfee5cs1c6744638e650fff@mail.gmail.com> <43C32A5D.8020807@computer.org> <4bd3e1480601092002m7f637397nef9654c5014f4785@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 83.145.96.118 User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux) Cancel-Lock: sha1:lPLPhyiGBi8T+3op7dsCqHPkZ+I= X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.253 required=5 tests=[AWL=-0.000, RCVD_NUMERIC_HELO=1.253] X-Spam-Score: 1.253 X-Spam-Level: * X-Archive-Number: 200601/38 X-Sequence-Number: 14489 Assad Jarrahian 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.