From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Travis Hoyt <thoyt@npc.net>
Cc: PG Explorer <pgmail@pgexplorer.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: function error
Date: Wed, 27 Mar 2002 12:37:07 -0800 (PST)
Message-ID: <20020327123521.D42156-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <DBEMKMGOMJAGKAKEPPEGGEAODHAA.thoyt@npc.net>
On Wed, 27 Mar 2002, Travis Hoyt wrote:
> Doh! Sorry my code DOES have the FOR in it as does the example in the
> book. Neither works though.
>
> My apologies this was my second attempt w/o the FOR.
>
> Here's what I really have:
>
> CREATE FUNCTION biwklyavg(text, text, text) RETURNS numeric AS '
> DECLARE
> system ALIAS FOR $1;
> startdate ALIAS FOR $2;
> enddate ALIAS FOR $3;
> result numeric;
>
> BEGIN
> result := (select (avg(usr) + avg(sys)) from sardata
> where
> systemid = system and time between startdate and enddate;
> END;
> ' LANGUAGE 'sql';
I think you want plpgsql not sql as the language.
There does appear to be a missing close paren on the result:= thing as
well.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone23.bigpanda.com, thoyt@npc.net, pgmail@pgexplorer.com
Subject: Re: function error
In-Reply-To: <20020327123521.D42156-100000@megazone23.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox