Plpgsql Question - Mailing list pgsql-general

From Oxeye
Subject Plpgsql Question
Date
Msg-id 003301c1d73f$bac32ff0$05a8a8c0@oxeye
Whole thread Raw
In response to Performance Tuning Document?  (Matthew Kirkwood <matthew@hairy.beasts.org>)
Responses Re: Plpgsql Question  ("Arguile" <arguile@lucentstudios.com>)
List pgsql-general
Hello,

I'm new to Postgresql and plpgslq. I wrote a plpgsql to return epoch time
from a table, but had problem running it. The error returned:

NOTICE:  Error occurred while executing PL/pgSQL function sleeptime
NOTICE:  line 10 at assignment
ERROR:  Bad timestamp external representation 'rec_runtime.runtime'

My plpgsql function:

create function sleeptime () returns float as '
declare
        rec_runtime record;
        ret_sleepsecs float;
begin
        select into rec_runtime runtime from mon_nextrun order by runtime
limit 1;
        if rec_runtime.runtime is null
        then
            return 60;
        end if;
        ret_sleepsecs := extract (epoch from timestamp
''rec_runtime.runtime'') as float;
        return ret_sleepsecs;
end;
' language 'plpgsql';

What is the correct syntax for extract function in the assignment statement?

Thanks in advance.

-CT



pgsql-general by date:

Previous
From: "Marin Dimitrov"
Date:
Subject: Re: Performance Tuning Document?
Next
From: "Steve Wolfe"
Date:
Subject: Re: Performance Tuning Document?