Hope Rule Is Willing To Discard Result Sets

From: "CN LIOU" <cnliou(at)graffiti(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Hope Rule Is Willing To Discard Result Sets
Date: 2003-01-10 07:58:29
Message-ID: 20030110075829.3520.qmail@graffiti.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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-have feature, I presume.

Regards,

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

Powered by Outblaze

Browse pgsql-general by date

  From Date Subject
Next Message Lincoln Yeoh 2003-01-10 08:19:46 Re: PostgreSQL/PHP: transactions: how-to abstract
Previous Message CN LIOU 2003-01-10 07:57:19 Stable function Repeatedly Called