Re: Prepared statements and default values

Поиск
Список
Период
Сортировка
От Assad Jarrahian
Тема Re: Prepared statements and default values
Дата
Msg-id 4bd3e1480601092002m7f637397nef9654c5014f4785@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Prepared statements and default values  (David Wall <d.wall@computer.org>)
Ответы Re: Prepared statements and default values  (Dave Cramer <pg@fastcrypt.com>)
Список pgsql-jdbc
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 <d.wall@computer.org> 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 = ? 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
> >
> >
> >
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: David Wall
Дата:
Сообщение: Re: Prepared statements and default values
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: Prepared statements and default values