Re: for looping

From: Michael Adler <adler(at)glimpser(dot)org>
To: Michael Labhard <ince(at)pacifier(dot)com>
Cc: pgsql-cygwin(at)postgresql(dot)org
Subject: Re: for looping
Date: 2002-08-04 17:36:55
Message-ID: Pine.NEB.4.44.0208041335540.9403-100000@reva.sixgirls.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

Mike

In response to

  • for looping at 2002-08-03 22:39:19 from Michael Labhard

Browse pgsql-cygwin by date

  From Date Subject
Next Message John S. Gage 2002-08-05 04:51:49 initdb hangs
Previous Message Michael Labhard 2002-08-03 22:39:19 for looping