| From: | Andy Colson <andy(at)squeakycode(dot)net> | 
|---|---|
| To: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Postgres 9 alpha 5 revised, stored proc | 
| Date: | 2010-04-08 01:28:12 | 
| Message-ID: | 4BBD312C.7030504@squeakycode.net | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2010-04-08 01:34:08 | Re: Postgres 9 alpha 5 revised, stored proc | 
| Previous Message | John R Pierce | 2010-04-07 22:46:13 | Re: [GENERAL] Solid State Drives with PG |