Re: Stable function Repeatedly Called

From: "CN LIOU" <cnliou(at)graffiti(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Stable function Repeatedly Called
Date: 2003-01-24 11:48:27
Message-ID: 20030124114827.4740.qmail@graffiti.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> However, when this is in rule, function f1 is called repeatedly again.

For example,

create table tt1 (c1 text,c2 text);
create table tt2 (c1 text,c2 text);
insert into tt1 values('a','aa');
insert into tt1 values('b','bb');
insert into tt1 values('c','cc');
insert into tt2 values('x','a');
insert into tt2 values('y','b');

CREATE OR REPLACE FUNCTION f1(TEXT) RETURNS TEXT AS'
DECLARE
MyNumber TEXT;
BEGIN
SELECT c2 INTO MyNumber FROM tt2 WHERE c1 = $1;
RAISE NOTICE ''%'',MyNumber; --for debug
RETURN MyNumber;
END' LANGUAGE 'plpgsql' STABLE;

CREATE RULE MyRule AS ON INSERT TO AnyTable DO update tt1 set c2='ABC' WHERE c1=(select f1('x'));

Thank you!

CN
--
_______________________________________________
Get your free email from http://www.graffiti.net

Powered by Outblaze

Browse pgsql-general by date

  From Date Subject
Next Message Dennis Gearon 2003-01-24 12:11:12 Re: I was spoiled by the MySQL timestamp field
Previous Message Ivar 2003-01-24 11:29:16 Re: ??? Multiple selects in procedure