one more word about rules - Mailing list pgsql-general

From Papp Gyozo
Subject one more word about rules
Date
Msg-id Pine.GSO.4.21.0009221329370.6305-100000@ural2
Whole thread Raw
In response to Re: rule with multiple DELETE action part  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: one more word about rules
List pgsql-general
First, thank youu for the accurate and exhausting answer.

And a new idea...  I've encountered a problem and I think rules would be
the nicest and the best solutions for it.  After SELECTing rows I need to
update some statistic fields such as timestamp of last reference and
number of all references up to now, etc.

In pgsql 7.0.2, there is no way to create a rule which can perform  an
additional query after SELECT. What I'm writing  about:

CREATE RULE r_my_dream AS ON SELECT TO xxx
DO UPDATE xxx SET c_lastref = current_timestamp, c_refnum = c_refnum + 1
WHERE xxx.oid = old.oid;

I know that this could be solved with FOR UPDATE clause and then with an
UPDATE query.
But, it would be so nice if it was totally transparent. (_only_one_ query)
Can my dream be realised?

Papp Gyozo

s7461pap@hszk.bme.hu, gerzson17@freemail.hu


pgsql-general by date:

Previous
From: Mathieu Arnold
Date:
Subject: data replication
Next
From: Fernán Agüero
Date:
Subject: Re: perl Pg module and result status