Re: Stable function Repeatedly Called
Thank you! Robert,
select * from tt1 where c1=(select f1('x'));
update tt1 set c2='ABC' WHERE c1=(select f1('x'));I think there might be other benefits to this in regards to index usage
as well.
Indeed this fix the problem.
However, when this is in rule, function f1 is called repeatedly again. Any idea?
Regards,
CN
--
_______________________________________________
Get your free email from http://www.graffiti.net
Powered by Outblaze
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
Import Notes
Resolved by subject fallback