Re: for looping

Поиск
Список
Период
Сортировка
От Michael Adler
Тема Re: for looping
Дата
Msg-id Pine.NEB.4.44.0208041335540.9403-100000@reva.sixgirls.org
обсуждение исходный текст
Ответ на for looping  ("Michael Labhard" <ince@pacifier.com>)
Список pgsql-cygwin
> Does FOR LOOP work on SELECT?  The following simple function looks good to
> me but does not compile because of "missing .. at end of SQL expression".

you need to the declare the row record

DECLARE
    row RECORD;
BEGIN

>
> CREATE FUNCTION get_all_diffs()
> RETURNS FLOAT AS '
> DECLARE
>  i INTEGER := 0;
> sym_diff FLOAT := 0.0;
>
> BEGIN
>  FOR row IN SELECT * FROM "tblTrades" LOOP
>   i := i+1;
>  END LOOP;
>
>  RETURN sym_diff;
> END;'
>
> LANGUAGE 'plpgsql'
> ;
>
> SELECT get_all_diffs();
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>

Mike


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

Предыдущее
От: "Michael Labhard"
Дата:
Сообщение: for looping
Следующее
От: "John S. Gage"
Дата:
Сообщение: initdb hangs