plpgsql extract epoch problem - Mailing list pgsql-general

From Darren Ferguson
Subject plpgsql extract epoch problem
Date
Msg-id 3F96B54E.9050801@crystalballinc.com
Whole thread Raw
Responses Re: plpgsql extract epoch problem  (Darren Ferguson <darren@crystalballinc.com>)
Re: plpgsql extract epoch problem  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
List pgsql-general
Hey all

I am trying to extract the epoch from a timestamp variable in plpgsql.
The function is as follows:

create or replace function test() returns integer as '
declare
  _test timestamp with time zone;
  _f integer;
begin
  _test := current_timestamp;
  _f := extract(epoch from timestamp _test);
  return _f;
end;' language 'plpgsql';

Any ideas why this will not work????

The error is as follows:
pts=> select test();
WARNING:  Error occurred while executing PL/pgSQL function test
WARNING:  line 6 at assignment
ERROR:  parser: parse error at or near "$1" at character 40

And that is the _test variable

Any help greatly apprechiated
Darren


pgsql-general by date:

Previous
From: Andreas Fromm
Date:
Subject: Re: poor cpu utilization on dual cpu box
Next
From: Darren Ferguson
Date:
Subject: Re: plpgsql extract epoch problem