Hope Rule Is Willing To Discard Result Sets

Started by CN LIOUover 23 years ago1 messagesgeneral
Jump to latest
#1CN LIOU
cnliou@graffiti.net

Hi!

Pgsql complains the result returned by the called function being not used:

CREATE RULE MyRule AS ON INSERT TO MyTable DO SELECT MyFunction(NEW.c1)

It also suggests PERFORM if the returned value wants to be discarded. However, there is no such syntax as:

CREATE RULE MyRule AS ON INSERT TO MyTable DO PERFORM MyFunction(NEW.c1)

I know the following combination of function and trigger achieves my goal:

CREATE FUNCTION tf() RETURNS TRIGGER AS '
BEGIN
PERFORM MyFunction(NEW.c1);
RETURN NEW;
END' LANGUAGE 'plpgsql'

CREATE TRIGGER MyTrigger AFTER INSERT ON MyTable FOR EACH ROW EXECUTE PROCEDURE tf();

Rule would be more concise than trigger + function in this case if it accepted unused result set. This is only a better-to-have feature, I presume.

Regards,

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

Powered by Outblaze