returning value from inside a transaction

From: "Matt" <m(at)a(dot)b>
To: pgsql-general(at)postgresql(dot)org
Subject: returning value from inside a transaction
Date: 2001-09-12 01:18:18
Message-ID: 9nmd3b$2ivp$1@news.tht.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

create table tez (i int);
insert into tez values(3);

create function tezt0(int) returns int as '
begin work;
lock table tez;
select * from tez as r;
commit work;

select tez.i;
' language 'sql';

select tezt0(1);
tezt0
-------
3
(1 row)

create function tezt1(int) returns timestamp as '
begin work;
lock table tez;
select now() as n;
commit work;
select n;
' language 'sql';
ERROR: Attribute 'n' not found

ok so it's a visibility error in my instance here but how can i get the
value returned from a function inside the transaction

a wrapper like this is the only way I can see to lock tables a 'plpgsql'
function updates.

"Functions and trigger procedures are always executed within a transaction
established by an outer query"

so how on earth do i do this and find out what my functions return!

TIA

Matt

Responses

Browse pgsql-general by date

  From Date Subject
Next Message cnliou 2001-09-12 01:20:44 Mail To pgsql-general No Seen In Newsgroup
Previous Message Barry Lind 2001-09-12 01:05:17 Re: Fwd: Re: unicode in 7.1