pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Tambet Matiisen <t.matiisen@aprote.ee>
To: Tomasz Myrta <jasiek@klaster.net>
To: pgsql-sql@postgresql.org
Subject: Re: pl/pgsql errors
Date: Mon, 3 Mar 2003 13:45:53 +0200
Message-ID: <000701c2e17a$71ebbe50$0e01a8c0@aprote.com> (raw)
References: <3E633D63.7050406@klaster.net>
----- Original Message -----
From: "Tomasz Myrta" <jasiek@klaster.net>
To: <pgsql-sql@postgresql.org>
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
view thread (3+ messages) latest in thread
Message-ID: <000701c2e17a$71ebbe50$0e01a8c0@aprote.com> Permalink: ../000701c2e17a$71ebbe50$0e01a8c0@aprote.com/ Also on: postgresql.org/message-id/000701c2e17a$71ebbe50$0e01a8c0@aprote.com ·
reply
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: t.matiisen@aprote.ee, jasiek@klaster.net Subject: Re: pl/pgsql errors In-Reply-To: <000701c2e17a$71ebbe50$0e01a8c0@aprote.com> * 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