Re: Problems with plpgsql and FOR loops - Mailing list pgsql-general

From Tom Lane
Subject Re: Problems with plpgsql and FOR loops
Date
Msg-id 7971.1077323042@sss.pgh.pa.us
Whole thread Raw
In response to Problems with plpgsql and FOR loops  (Bill Moran <wmoran@potentialtech.com>)
Responses Re: Problems with plpgsql and FOR loops  (Bill Moran <wmoran@potentialtech.com>)
List pgsql-general
Bill Moran <wmoran@potentialtech.com> writes:
> Some of the plpgsql functions I've created work fine on 7.4, but
> fail on 7.3.4.  Specifically, when I use a "FOR var IN select LOOP"
> loop with a LONG select statement, it works fine on 7.4, but
> bonks with "missing .. at end of SQL expression" in 7.3.4

That error message suggests that plpgsql thinks the "var" is not
declared as a record or rowtype variable.  I think you should look
to the variable declaration as the source of the issue, not the FOR
statement itself.  There were some 7.4 fixes associated with
plpgsql rowtype variables, for instance this one:

2003-04-27 18:21  tgl

    * doc/src/sgml/plpgsql.sgml, src/pl/plpgsql/src/gram.y,
    src/pl/plpgsql/src/pl_comp.c, src/pl/plpgsql/src/plpgsql.h: Fix
    plpgsql so that variables of composite types (rowtypes) can be
    declared without having to write %ROWTYPE.  If the declared type of
    a variable is a composite type, it'll be taken to be a row variable
    automatically.

although my recollection is that without %ROWTYPE, 7.3 plpgsql would
fail on the variable declaration.

            regards, tom lane

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: postgresql system column errors
Next
From: Bill Moran
Date:
Subject: Re: Problems with plpgsql and FOR loops