X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 915034758F1 for ; Mon, 3 Mar 2003 06:45:54 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 36876-05 for ; Mon, 3 Mar 2003 06:45:52 -0500 (EST) Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) by postgresql.org (Postfix) with ESMTP id C23FE475843 for ; Mon, 3 Mar 2003 06:45:51 -0500 (EST) Received: Message by Barricade ns.aprote.ee with ESMTP id h23BlV624203 for ; Mon, 3 Mar 2003 13:47:31 +0200 Received: from TAMBETM ([192.168.1.14]) by black.aprote.com with Microsoft SMTPSVC(5.0.2195.5329); Mon, 3 Mar 2003 13:45:53 +0200 Message-ID: <000701c2e17a$71ebbe50$0e01a8c0@aprote.com> From: "Tambet Matiisen" To: "Tomasz Myrta" , References: <3E633D63.7050406@klaster.net> Subject: Re: pl/pgsql errors Date: Mon, 3 Mar 2003 13:45:53 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-OriginalArrivalTime: 03 Mar 2003 11:45:53.0376 (UTC) FILETIME=[71F24E00:01C2E17A] X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/63 X-Sequence-Number: 12103 ----- Original Message ----- From: "Tomasz Myrta" To: Sent: Monday, March 03, 2003 1:32 PM Subject: [SQL] pl/pgsql errors > Hi > > create function.... > declare > some_field integer; > begin > some_field=1; > insert into some_table (some_field) values (some_field); > end; > > When we try to execute such function, we get: > "ERROR: parser: parse error at or near "$1" at character..." > Well, example above is clear enough to find, that I declared field with > the same name as in a table. I lost a lot of time trying to find mistake > inside long functions until I remembered, what this strange error mean. > > Would it be difficult to add special ERROR for this case? It annoyed me > so many times... > Probably some_field was declared as alias for $1. I think plpgsql does simple find&replace for aliases, that's how $1 appeared in wrong place. I usually prefix all procedure parameters with p_, this guards me against this situation and also makes code more clear. Tambet