Re: Local variable and column name conflict

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Daniel Caune" <daniel(dot)caune(at)ubisoft(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Local variable and column name conflict
Date: 2006-07-03 15:37:54
Message-ID: 3434.1151941074@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Daniel Caune" <daniel(dot)caune(at)ubisoft(dot)com> writes:
> CREATE OR REPLACE FUNCTION foo(i IN int)
> RETURNS void
> AS $$
> BEGIN
> UPDATE bar
> SET i = i; // column i = parameter i
> END;
> $$ LANGUAGE PLPGSQL;

In SELECTs you can qualify the column, ie, bar.i vs i. That doesn't
work for an UPDATE target, though, so probably the best answer is
"don't do that". I think it's entirely too error-prone anyway ...

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Beutin 2006-07-03 15:54:08 Re: join two tables with sharing some columns between two
Previous Message Daniel Caune 2006-07-03 15:34:36 Local variable and column name conflict