Re: pgpsql help - Mailing list pgsql-general

From Tom Lane
Subject Re: pgpsql help
Date
Msg-id 23179.1105939903@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgpsql help  ("Mike G." <mike@thegodshalls.com>)
List pgsql-general
"Mike G." <mike@thegodshalls.com> writes:
> Maybe it is because 'name' is a sql 92/99 non-reserved / key word?

No, it's because of careless choice of plpgsql variable names.

>> declare
>> uri alias for $3;
>> ...
>> insert into uri (articleid,uri,uritype) values (article_id,uri,urit_id);
               ^^^            ^^^                             ^^^

Not being exceedingly bright, plpgsql will attempt to substitute its
variable into all three matches in this command.  Two of those are
of course wrong and lead to syntax errors.

First rule of plpgsql programming: do not use plpgsql variable names
that duplicate any of the SQL-level names (tables, columns, functions,
etc) you intend to use in the function.

            regards, tom lane

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: pgpsql help
Next
From: mstory@uchicago.edu
Date:
Subject: deleting from arrays