Hope Rule Is Willing To Discard Result Sets - Mailing list pgsql-general

From CN LIOU
Subject Hope Rule Is Willing To Discard Result Sets
Date
Msg-id 20030110075829.3520.qmail@graffiti.net
Whole thread Raw
List pgsql-general
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-havefeature, I presume. 

Regards,

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

Powered by Outblaze

pgsql-general by date:

Previous
From: "CN LIOU"
Date:
Subject: Stable function Repeatedly Called
Next
From: Lincoln Yeoh
Date:
Subject: Re: PostgreSQL/PHP: transactions: how-to abstract