Re: function error

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: function error
Дата
Msg-id 20020327123521.D42156-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Re: function error  ("Travis Hoyt" <thoyt@npc.net>)
Список pgsql-sql
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.




В списке pgsql-sql по дате отправления:

Предыдущее
От: Jan Wieck
Дата:
Сообщение: Re: function error
Следующее
От: Rudi Starcevic
Дата:
Сообщение: psql and password