X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3D31D535C2 for ; Sun, 27 Mar 2005 17:01:50 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 48899-02 for ; Sun, 27 Mar 2005 16:01:44 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 698E653557 for ; Sun, 27 Mar 2005 17:01:44 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2RG1goY005600; Sun, 27 Mar 2005 11:01:42 -0500 (EST) To: "Franz Stuetzle" Cc: pgsql-sql@postgresql.org Subject: Re: Postgre: 8.0.1 Create Table insde a function gives strange error at execution time In-reply-to: <20050327121735.AFA9853A9E@svr1.postgresql.org> References: <20050327121735.AFA9853A9E@svr1.postgresql.org> Comments: In-reply-to "Franz Stuetzle" message dated "Sun, 27 Mar 2005 14:17:38 +0200" Date: Sun, 27 Mar 2005 11:01:42 -0500 Message-ID: <5599.1111939302@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/358 X-Sequence-Number: 20837 "Franz Stuetzle" 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