plpgsql - TIMESTAMP variables in EXTRACT

Поиск
Список
Период
Сортировка
От Matthew Phillips
Тема plpgsql - TIMESTAMP variables in EXTRACT
Дата
Msg-id 42B073CC.8050007@timing.com
обсуждение исходный текст
Ответы Re: plpgsql - TIMESTAMP variables in EXTRACT  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-general
Hi all,

I have the following in a plpgsql proc on 7.3.4:

<code>
DECLARE
...
curTime TIMESTAMP;
ppsCnt  INT;

BEGIN
...

-- this works
SELECT INTO curTime localtimestamp;

-- get unix seconds from current time (doesn't work)
SELECT INTO ppsCnt EXTRACT (EPOCH FROM TIMESTAMP curTime );
--               parser complains here ^

-- get unix seconds from random string (works)
SELECT INTO ppsCnt EXTRACT (EPOCH FROM TIMESTAMP
     \'1990-05-04 01:02:03\' );

-- do stuff with ppsCnt and curTime
...

</code>

Here are the error messages:
WARNING:  Error occurred while executing PL/pgSQL function XXX
WARNING:  line XXX at select into variables
ERROR:  parser: parse error at or near "$1" at character XX

All I would like to do is get the current time and convert
it to an integer value. Am I attempting to do the impossible or
is this another simpler way to shove unix seconds of the current
time in a variable? Please also inform me as to why my current
syntax is invalid.

Thanks,
Matthew


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

Предыдущее
От: Matt Miller
Дата:
Сообщение: Re: enebling regular user to create new users ?
Следующее
От: uruz
Дата:
Сообщение: graphic client