I have this stored proc that works in pg 8.4.

create or replace function roundts(ts timestamp) returns timestamp as $$
declare
        tmp integer;
        result timestamp;
        offset interval;
begin
        tmp := extract(second from ts);
        if tmp > 30 then
                tmp := 60 - tmp;
                offset := tmp || ' seconds';
                result := ts + offset;
        else
                offset := tmp || ' seconds';
                result := ts - offset;
        end if;

        tmp := extract(minute from result);
        if tmp > 30 then
                tmp := 60 - tmp;
                offset := tmp || ' minutes';
                result := result + offset;
        else
                offset := tmp || ' minutes';
                result := result - offset;
        end if;

        return result;
end; $$ language plpgsql;


In 9 I get an error when trying to create it:

$ psql < roundts.sql
Timing is on.
CREATE FUNCTION
Time: 26.716 ms
ERROR:  syntax error at or near "offset"
LINE 11:   result := ts + offset;
                          ^

Just wanted to report it.

-Andy

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to