Re: timestamp/function question

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: timestamp/function question
Дата
Msg-id 22404.985881394@sss.pgh.pa.us
обсуждение исходный текст
Ответ на timestamp/function question  (Soma Interesting <dfunct@telus.net>)
Ответы Re: timestamp/function question
Список pgsql-general
Soma Interesting <dfunct@telus.net> writes:
> Why does the following code return the exact same value each time, instead
> of a value based on the current time?

> CREATE FUNCTION memb_num () RETURNS INT4 AS '
>     BEGIN
>         RETURN date_part(''epoch'', CURRENT_DATE);
>     END;
> ' LANGUAGE 'plpgsql';

Because you asked for a value based on the current *date*.
If you waited till tomorrow and tried again, then you'd get a
different answer.  Perhaps you want

         RETURN date_part(''epoch'', CURRENT_TIMESTAMP);

            regards, tom lane

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

Предыдущее
От: "chris markiewicz"
Дата:
Сообщение: ExecSQL NullPtrEx...conn timeout?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Pgsql-7.1RC1: SET SEED =