| From: | "Tambet Matiisen" <t(dot)matiisen(at)aprote(dot)ee> | 
|---|---|
| To: | "Tomasz Myrta" <jasiek(at)klaster(dot)net>, <pgsql-sql(at)postgresql(dot)org> | 
| Subject: | Re: pl/pgsql errors | 
| Date: | 2003-03-03 11:45:53 | 
| Message-ID: | 000701c2e17a$71ebbe50$0e01a8c0@aprote.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-sql | 
----- Original Message -----
From: "Tomasz Myrta" <jasiek(at)klaster(dot)net>
To: <pgsql-sql(at)postgresql(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Achilleus Mantzios | 2003-03-03 12:01:17 | Re: Dynamic SELECT condition | 
| Previous Message | Tomasz Myrta | 2003-03-03 11:32:51 | pl/pgsql errors |