Re: PL/pgSQL loops? - Mailing list pgsql-sql

From Tom Lane
Subject Re: PL/pgSQL loops?
Date
Msg-id 15769.1007014116@sss.pgh.pa.us
Whole thread Raw
In response to Re: PL/pgSQL loops?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Responses Re: PL/pgSQL loops?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-sql
Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> Something like the below seemed to make it work for me under
> 7.2b3:

Oh ... duh!  I've been bit by that before myself.  In the original,
since the FOR loops were using integer variables (not record or rowtype
variables as they should've), the plpgsql parser was expecting an
integer FOR-loop.  Which goes like
FOR ivar IN expression .. expression LOOP stmts END LOOP;

Evidently, somewhere around the END LOOP it realized that it was missing
the .. part of the construct.

I've mumbled before that it's bad form to be using the declared type
of the FOR variable to drive the syntaxing of FOR loops --- poor error
recovery and unhelpful error messages are exactly the reasons why.
Not sure that this can easily be fixed, however.
        regards, tom lane


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Return Opaque / Error in Function
Next
From: Markus Bertheau
Date:
Subject: date_part vs extract