Received: from homer.websystems.co.za (unknown [196.25.70.70]) by postgresql.org (Postfix) with ESMTP id D3F4147593C for ; Wed, 27 Mar 2002 15:06:41 -0500 (EST) Received: from hano (bnb53-01-p104.nt.saix.net [155.239.180.104]) by homer.websystems.co.za (8.11.0/8.11.0) with SMTP id g2RKFHQ32011; Wed, 27 Mar 2002 22:15:17 +0200 Message-ID: <002601c1d5ca$e2ed5800$c80ba8c0@sabex.com> From: "PG Explorer" To: "Travis Hoyt" , References: Subject: Re: function error Date: Wed, 27 Mar 2002 22:06:29 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200203/363 X-Sequence-Number: 7237 Needs a FOR!! system ALIAS FOR $1; Strange that the sample is wrong? http://www.pgexplorer.com ----- Original Message ----- From: "Travis Hoyt" To: 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 >