Postgres 9 alpha 5 revised, stored proc - Mailing list pgsql-general

From Andy Colson
Subject Postgres 9 alpha 5 revised, stored proc
Date
Msg-id 4BBD312C.7030504@squeakycode.net
Whole thread Raw
Responses Re: Postgres 9 alpha 5 revised, stored proc  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
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

pgsql-general by date:

Previous
From: Gordan Bobic
Date:
Subject: Re: Solid State Drives with PG
Next
From: Tom Lane
Date:
Subject: Re: Postgres 9 alpha 5 revised, stored proc