Re: Date variables in psql

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Date variables in psql
Дата
Msg-id 181.1097169950@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Date variables in psql  (Francisco Reyes <lists@natserv.com>)
Ответы Re: Date variables in psql
Список pgsql-general
Francisco Reyes <lists@natserv.com> writes:
> Trying the following simple sql file:
> \set proc_date 6/30/2004
> \echo Date is :proc_date
> select * from feeds where date = :proc_date limit 20;

That's going to expand to

select * from feeds where date = 6/30/2004 limit 20;

whereas what you need is

select * from feeds where date = '6/30/2004' limit 20;

It's fairly painful to get single quotes into a psql variable;
AFAIK you have to do it like this:

\set proc_date '\'6/30/2004\''

            regards, tom lane

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