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 3DB6D52D34 for ; Thu, 14 Jul 2005 05:16:21 -0300 (ADT) 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 15961-05 for ; Thu, 14 Jul 2005 08:16:12 +0000 (GMT) Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by svr1.postgresql.org (Postfix) with ESMTP id 136FE52CDF for ; Thu, 14 Jul 2005 05:16:09 -0300 (ADT) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 5D91D41565F; Thu, 14 Jul 2005 09:15:51 +0100 (BST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 31B1615EDA; Thu, 14 Jul 2005 09:14:21 +0100 (BST) Received: from mainbox.archonet.com ([127.0.0.1]) by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 08464-06; Thu, 14 Jul 2005 09:14:16 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 3E75515ED9; Thu, 14 Jul 2005 09:14:16 +0100 (BST) Message-ID: <42D61ED7.1040707@archonet.com> Date: Thu, 14 Jul 2005 09:14:15 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Richard Hayward Cc: pgsql-sql@postgresql.org Subject: Re: function parameters : bug? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.056 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200507/122 X-Sequence-Number: 22100 Richard Hayward wrote: > pg 8.0.3 > This behaviour seems odd to me: > > CREATE TABLE mytable ( > inta INTEGER > ); > > CREATE OR REPLACE FUNCTION myfunction (inta integer) RETURNS integer > AS > $body$ > begin > insert into mytable(inta) values (inta); > ERROR: syntax error at or near "$1" at character 22 > QUERY: insert into myTable( $1 ) values ( $2 ) > CONTEXT: PL/pgSQL function "myfunction" line 2 at SQL statement > > The problem is with the line in my myfunction: > insert into mytable(inta) values (inta); > > The server doesn't like the field name being the same as the name of > the function parameter. I don't see why, as I can see no opportunity > for ambiguity. So what would this do? SELECT inta+1 FROM mytable Agreed, it's tricky, but without some variable marker (e.g. $my_param) or removing inline SQL from the language, I'm not sure there's much to do. -- Richard Huxton Archonet Ltd