Re: avoid replace of column with variable in pgsql function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gerhard Heift <ml-postgresql-20081012-3518(at)gheift(dot)de>
Cc: PostgreSQL general <pgsql-general(at)postgresql(dot)org>
Subject: Re: avoid replace of column with variable in pgsql function
Date: 2008-11-16 23:49:11
Message-ID: 14484.1226879351@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gerhard Heift <ml-postgresql-20081012-3518(at)gheift(dot)de> writes:
> I have a function with an out variable in which I have an INSERT
> statement with the same name as column. Is it possible to avoid the
> replacement?

No, but you could rename the variable. If you don't want to change the
externally exposed name, try using RENAME:

CREATE FUNCTION insert_foo(IN bar integer, OUT id integer) AS
$BODY$
declare rename id to _id;
BEGIN
INSERT INTO t1 (id, value) VALUES (bar, bar || '-bar');
SELECT id INTO _id FROM ...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christiaan Willemsen 2008-11-17 08:51:45 Re: FreeBSD 7 needing to allocate lots of shared memory
Previous Message Gerhard Heift 2008-11-16 23:35:50 avoid replace of column with variable in pgsql function