From: Tom Lane <tgl@sss.pgh.pa.us>
To: Franz Stuetzle <franz.stuetzle@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Postgre: 8.0.1 Create Table insde a function gives strange error at execution time
Date: Sun, 27 Mar 2005 11:01:42 -0500
Message-ID: <5599.1111939302@sss.pgh.pa.us> (raw)
In-Reply-To: <20050327121735.AFA9853A9E@svr1.postgresql.org>
References: <20050327121735.AFA9853A9E@svr1.postgresql.org>
"Franz Stuetzle" <franz.stuetzle@gmx.net> writes:
> ERROR: syntax error at or near "$1" bei Zeichen 87
> ANFRAGE: CREATE TEMPORARY TABLE globals_pac_adressarten (INT_ALIAS_NAME
> VARCHAR(12) NOT NULL , $1 SMALLINT NOT NULL ,
> $2 SMALLINT NOT NULL ) WITHOUT OIDS ON COMMIT PRESERVE ROWS
> Would anybody know where those $1 and $2 come from?
Undoubtedly they are from plpgsql variable substitution. As a general
rule, variables in a plpgsql function should never be named the same as
any table or field name that you need to access in that function,
because plpgsql isn't smart enough to tell whether it ought to
substitute its variable for a reference or not. It will always do so,
even in cases where there arguably might be a way for it to tell that
it shouldn't (and there are cases where it simply couldn't tell, anyway).
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, franz.stuetzle@gmx.net
Subject: Re: Postgre: 8.0.1 Create Table insde a function gives strange error at execution time
In-Reply-To: <5599.1111939302@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox