Skip site navigation (1) Skip section navigation (2)

Re: Prepared statements and default values

From: David Wall <d(dot)wall(at)computer(dot)org>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Prepared statements and default values
Date: 2006-01-10 03:30:37
Message-ID: 43C32A5D.8020807@computer.org (view raw or flat)
Thread:
Lists: pgsql-jdbc
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 = ? where username = ?

If you want to specify, then use:

UPDATE usersettings SET gpsfrequency = ? , serverurl = ? where username = ?

David


Assad Jarrahian wrote:

>I have a preparedStatement with the following query
> "UPDATE usersettings SET gpsfrequency = ? , serverurl = ? where
>username = ? ;";
>
>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(""))==0)
>	<what goes here> //pick up the default value from the db.
>else	
>	setUserSettings.setInt(++i,
>Integer.parseInt(client.getSettings().getField(Settings.GPS_FREQUENCY)));
>			
>
><what goes here> .. 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
>
>  
>

In response to

Responses

pgsql-jdbc by date

Next:From: Assad JarrahianDate: 2006-01-10 04:02:18
Subject: Re: Prepared statements and default values
Previous:From: Assad JarrahianDate: 2006-01-10 03:24:37
Subject: Prepared statements and default values

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group