Re: Querying now()

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: Querying now()
Дата
Msg-id 1B15B3D8-5222-11D9-93E5-000A95C88220@myrealbox.com
обсуждение исходный текст
Ответ на Querying now()  (A Gilmore <agilmore@shaw.ca>)
Список pgsql-novice
On Dec 20, 2004, at 9:05, A Gilmore wrote:

> Id like my application to do something like this :
>
> SELECT now() AS currentTime WHERE currentTime < '$timestamp';
>
> So if it returns a row Id know $timestamp is not in the past.  However
> when you run this it simply says 'ERROR:  column "currentTime" does
> not exist'.

AFAIK, SELECT clause aliases are not available to any other part of the
query: it's looking for a column called currentTime, but there isn't
one in the FROM clause tables. Then again, you don't even have a FROM
clause. :) In general, it's best to show the exact query you're trying
and the error messages you're getting--and if possible, reduce it to a
test case that still exhibits the problem.

You probably want something like:

SELECT foo FROM bar WHERE current_timestamp < baz;

( current_timestamp is the SQL standard spelling of the PostgreSQL
alternative now(). )

Also note that all identifiers are converted to lowercase unless
double-quoted. PostgreSQL sees currentTime as currenttime.

Hope this helps.


Michael Glaesemann
grzm myrealbox com


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Querying now()
Следующее
От: A Gilmore
Дата:
Сообщение: Re: Querying now()