variable name in plpgsql

From: zhong ming wu <mr(dot)z(dot)m(dot)wu(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: variable name in plpgsql
Date: 2010-09-09 00:23:20
Message-ID: AANLkTinURvsQys6TPd=Vni_+1cLFu0Mb456GVGBFuhqs@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

It seems that one cannot use the variable name that is the same as the
column name of a relation like in the following function

------
create or replace function bla() returns void language plpgsql as $$
declare
email varchar;
begin
select email into email from pass where id=1;
raise notice 'pass is %',email;
end;
$$
------
I get null value email and postgres 8.4.4 does not warn nor raise
error on creating;
I know for a fact that email must not be null; it's not null when I
rename the variable
email to something else.

As far as I can see this isn't documented anywhere. Is this because
it's common/insider knowledge? Can someone confirm?

Thanks

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2010-09-09 00:30:15 Re: Empty SELECT result at simultaneous calls
Previous Message Scott Ribe 2010-09-09 00:03:18 Re: "private" installation of postgres