From: Travis Hoyt <thoyt@npc.net>
To: PG Explorer <pgmail@pgexplorer.com>
To: pgsql-sql@postgresql.org
Subject: Re: function error
Date: Wed, 27 Mar 2002 15:10:06 -0500
Message-ID: <DBEMKMGOMJAGKAKEPPEGGEAODHAA.thoyt@npc.net> (raw)
In-Reply-To: <002601c1d5ca$e2ed5800$c80ba8c0@sabex.com>
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';
-----Original Message-----
From: PG Explorer [mailto:pgmail@pgexplorer.com]
Sent: Wednesday, March 27, 2002 3:06 PM
To: Travis Hoyt; pgsql-sql@postgresql.org
Subject: Re: [SQL] function error
Needs a FOR!!
system ALIAS FOR $1;
Strange that the sample is wrong?
http://www.pgexplorer.com
----- Original Message -----
From: "Travis Hoyt" <thoyt@npc.net>
To: <pgsql-sql@postgresql.org>
Sent: Wednesday, March 27, 2002 9:59 PM
Subject: [SQL] function error
> CREATE FUNCTION biwklyavg(text, text, text) RETURNS numeric AS '
> DECLARE
> system ALIAS $1;
> startdate ALIAS $2;
> enddate ALIAS $3;
> result numeric;
>
> BEGIN
> result := (select (avg(usr) + avg(sys)) from sardata
where
> systemid = system
> and time between startdate and enddate;
> END;
> ' LANGUAGE 'sql';
>
> Hello,
>
> The fuction listed above gives the following error:
>
> ERROR: parser: parse error at or near "alias"
>
> I'm running v7.2. Any ideas? I pulled this directly from the examples
in
> the PostgreSQL Developer's Handbook.
>
> Thanks,
>
> Travis
>
Attachments:
smime.p7s (application/x-pkcs7-signature, 3.0K) download
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: thoyt@npc.net, pgmail@pgexplorer.com
Subject: Re: function error
In-Reply-To: <DBEMKMGOMJAGKAKEPPEGGEAODHAA.thoyt@npc.net>
* 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