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 E585B9DC83C for ; Tue, 10 Jan 2006 00:02:21 -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 95307-03 for ; Tue, 10 Jan 2006 00:02:20 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.197]) by postgresql.org (Postfix) with ESMTP id B01CD9DC827 for ; Tue, 10 Jan 2006 00:02:19 -0400 (AST) Received: by zproxy.gmail.com with SMTP id v1so1375335nzb for ; Mon, 09 Jan 2006 20:02:18 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=AXHKIrChU17r3MzzwO0BRmXFZM1yBZ7RdO/LC65d9ci5K4/RkOylzO3VF/aKAdHuh+qJK/v1hhH2/vwPUI/rfS6DhpSYaux6SNXbvAJCgBAAIP1ODCyfIiQL2Knn08Cg5cO0f/vWsmzV5/62SN0ZnvC/nAnHgD9ZXoWlrgPQpUo= Received: by 10.65.119.10 with SMTP id w10mr2895873qbm; Mon, 09 Jan 2006 20:02:18 -0800 (PST) Received: by 10.65.95.1 with HTTP; Mon, 9 Jan 2006 20:02:18 -0800 (PST) Message-ID: <4bd3e1480601092002m7f637397nef9654c5014f4785@mail.gmail.com> Date: Mon, 9 Jan 2006 21:02:18 -0700 From: Assad Jarrahian To: David Wall Subject: Re: Prepared statements and default values Cc: pgsql-jdbc@postgresql.org In-Reply-To: <43C32A5D.8020807@computer.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4bd3e1480601091924q54cfee5cs1c6744638e650fff@mail.gmail.com> <43C32A5D.8020807@computer.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.126 required=5 tests=[AWL=0.126] X-Spam-Score: 0.126 X-Spam-Level: X-Archive-Number: 200601/36 X-Sequence-Number: 14487 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? thanks. -assad On 1/9/06, David Wall wrote: > You'll probably need to use two statements, so that when you want to use > the default, you don't specify anything, and when you want a special > value, you use the command you gave. > > If you want the default, use: > > UPDATE usersettings SET serverurl =3D ? where username =3D ? > > If you want to specify, then use: > > UPDATE usersettings SET gpsfrequency =3D ? , serverurl =3D ? where userna= me =3D ? > > David > > > Assad Jarrahian wrote: > > >I have a preparedStatement with the following query > > "UPDATE usersettings SET gpsfrequency =3D ? , serverurl =3D ? where > >username =3D ? ;"; > > > >In the db, the table userSettings has a default value specified for > >gps_frequency . > > > >So when I write code > >if (client.getSettings().getField(Settings.GPS_FREQUENCY).compareTo(""))= =3D=3D0) > > //pick up the default value from the db. > >else > > setUserSettings.setInt(++i, > >Integer.parseInt(client.getSettings().getField(Settings.GPS_FREQUENCY)))= ; > > > > > > .. I basically want to send something that lets the > >db know to use the DEFAULT value. (its of type int0) > > > >So what does go here? > > > >any help would be much appreciated. > > > >-a > > > >---------------------------(end of broadcast)--------------------------- > >TIP 2: Don't 'kill -9' the postmaster > > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend >