one more word about rules

From: Papp Gyozo <s7461pap(at)hszk(dot)bme(dot)hu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: one more word about rules
Date: 2000-09-22 11:43:51
Message-ID: Pine.GSO.4.21.0009221329370.6305-100000@ural2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)hszk(dot)bme(dot)hu, gerzson17(at)freemail(dot)hu

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Good 2000-09-22 13:30:47 Re: perl Pg module and result status
Previous Message Mathieu Arnold 2000-09-22 09:40:19 data replication