From: | James Robinson <jlrobins(at)socialserve(dot)com> |
---|---|
To: | pgsql-docs(at)postgresql(dot)org |
Subject: | plpgsql, declare blocks, and '=' versus ':=' |
Date: | 2008-07-11 16:25:35 |
Message-ID: | 52962000-14ED-4BC2-8F5D-520F238FA78D@socialserve.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs |
It seems that [ in 8.2.9 at least ], in a plpgsql declare block,
assignment to declared variable can use either the proper ':='
operator or the unexpected and undocumented '=' operator. See
following script. The magic handling of '=' ought to get documented at
least.
[ plpgsql-declarations.html makes no mention of '=' token handling in
either 8.3 or 8.2. docs ]
---
create or replace function test_1() returns int as
$$
declare
value int = 12; -- wow -- no colon!
begin
return value;
end;
$$ language plpgsql;
create or replace function test_2() returns int as
$$
declare
value int := 14; -- correct
begin
return value;
end;
$$ language plpgsql;
select test_1();
-- returns 12
select test_2();
-- returns 14
-----
----
James Robinson
Socialserve.com
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2008-07-11 17:08:03 | Re: plpgsql, declare blocks, and '=' versus ':=' |
Previous Message | Laurent Buffat | 2008-07-09 17:46:17 | quote text array |