Обсуждение: DBD::Pg ... how would I format this prepare?

Поиск
Список
Период
Сортировка

DBD::Pg ... how would I format this prepare?

От
"Marc G. Fournier"
Дата:
I need to do:

NOW() + '2 day'::interval

where 2 is a variable ...

if I do:

NOW() + '? day'::interval

it, of course, takes the ? as a literal ... so is there some way I can do 
this such that I can do the placeholder?

Thx

----
Marc G. Fournier           Hub.Org Networking Services (http://www.hub.org)
Email . scrappy@hub.org                              MSN . scrappy@hub.org
Yahoo . yscrappy               Skype: hub.org        ICQ . 7615664


Re: DBD::Pg ... how would I format this prepare?

От
Tom Lane
Дата:
"Marc G. Fournier" <scrappy@postgresql.org> writes:
> if I do:
> NOW() + '? day'::interval
> it, of course, takes the ? as a literal ... so is there some way I can do 
> this such that I can do the placeholder?

NOW() + n * '1 day'::interval

n can be any numeric value ...
        regards, tom lane


Re: DBD::Pg ... how would I format this prepare?

От
"Jim Buttafuoco"
Дата:
try 

now() + (? || ' day')::interval


---------- Original Message -----------
From: "Marc G. Fournier" <scrappy@postgresql.org>
To: pgsql-sql@postgresql.org
Sent: Wed, 26 Jul 2006 18:29:32 -0300 (ADT)
Subject: [SQL] DBD::Pg ... how would I format this prepare?

> I need to do:
> 
> NOW() + '2 day'::interval
> 
> where 2 is a variable ...
> 
> if I do:
> 
> NOW() + '? day'::interval
> 
> it, of course, takes the ? as a literal ... so is there some way I can do 
> this such that I can do the placeholder?
> 
> Thx
> 
> ----
> Marc G. Fournier           Hub.Org Networking Services (http://www.hub.org)
> Email . scrappy@hub.org                              MSN . scrappy@hub.org
> Yahoo . yscrappy               Skype: hub.org        ICQ . 7615664
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faq
------- End of Original Message -------



Re: DBD::Pg ... how would I format this prepare?

От
"Marc G. Fournier"
Дата:
On Wed, 26 Jul 2006, Jim Buttafuoco wrote:

> try
>
> now() + (? || ' day')::interval

Perfect ... had thought of that, but put my ) after ::interval instead of 
before ;(

Thx ...


>
>
> ---------- Original Message -----------
> From: "Marc G. Fournier" <scrappy@postgresql.org>
> To: pgsql-sql@postgresql.org
> Sent: Wed, 26 Jul 2006 18:29:32 -0300 (ADT)
> Subject: [SQL] DBD::Pg ... how would I format this prepare?
>
>> I need to do:
>>
>> NOW() + '2 day'::interval
>>
>> where 2 is a variable ...
>>
>> if I do:
>>
>> NOW() + '? day'::interval
>>
>> it, of course, takes the ? as a literal ... so is there some way I can do
>> this such that I can do the placeholder?
>>
>> Thx
>>
>> ----
>> Marc G. Fournier           Hub.Org Networking Services (http://www.hub.org)
>> Email . scrappy@hub.org                              MSN . scrappy@hub.org
>> Yahoo . yscrappy               Skype: hub.org        ICQ . 7615664
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 3: Have you checked our extensive FAQ?
>>
>>                http://www.postgresql.org/docs/faq
> ------- End of Original Message -------
>
>

----
Marc G. Fournier           Hub.Org Networking Services (http://www.hub.org)
Email . scrappy@hub.org                              MSN . scrappy@hub.org
Yahoo . yscrappy               Skype: hub.org        ICQ . 7615664


Re: DBD::Pg ... how would I format this prepare?

От
Mathieu Arnold
Дата:
+-le 26/07/2006 18:29 -0300, Marc G. Fournier a dit :
| 
| I need to do:
| 
| NOW() + '2 day'::interval
| 
| where 2 is a variable ...
| 
| if I do:
| 
| NOW() + '? day'::interval
| 
| it, of course, takes the ? as a literal ... so is there some way I can do
| this such that I can do the placeholder?

I think that ! is what you're looking for.

-- 
Mathieu Arnold


Re: DBD::Pg ... how would I format this prepare?

От
Harald Fuchs
Дата:
In article <20060726182806.A1188@ganymede.hub.org>,
"Marc G. Fournier" <scrappy@postgresql.org> writes:

> I need to do:

> NOW() + '2 day'::interval

> where 2 is a variable ...

> if I do:

> NOW() + '? day'::interval

> it, of course, takes the ? as a literal ... so is there some way I can
> do this such that I can do the placeholder?

How about the following?
 now() + ? * '1 day'::interval