Re: at for over select rows - Mailing list pgsql-bugs

From Tom Lane
Subject Re: at for over select rows
Date
Msg-id 14093.1054181590@sss.pgh.pa.us
Whole thread Raw
In response to at for over select rows  (al_nunes@atua.com.br)
List pgsql-bugs
al_nunes@atua.com.br writes:
> NOTICE:  Error occurred while executing PL/pgSQL function apaga_constraint
> NOTICE:  line 20 at for over select rows
> ERROR:  parser: parse error at or near "$1"

> DECLARE
>   qtd        INTEGER;
    ^^^

>       FOR registro IN
>         SELECT t.tgrelid, COUNT(t.tgname) AS qtd
                                               ^^^

Never use a name in an SQL statement that is the same as a name you've
declared as a plpgsql variable, unless your intent is for the value of
that variable to be substituted at that point in the statement.  Which
is certainly not what you want here.

            regards, tom lane

pgsql-bugs by date:

Previous
From: al_nunes@atua.com.br
Date:
Subject: at for over select rows
Next
From: Sean Chittenden
Date:
Subject: Re: segv's on CREATE INDEX with recent HEAD...