pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: marc@oscar.eng.cv.net
To: pgsql-sql@postgresql.org
Subject: should this be a trigger or a rule?
Date: Sun, 16 Dec 2001 00:16:52 GMT
Message-ID: <slrna1npu6.1s6p.marc@oscar.eng.cv.net> (raw)

I have 3 tables: pings, curr_state, ping_log and here is what I want
to happen:
when I insert a row into pings it checks to see if the ping was
sucessful or not.  Then it checks the current state of the interface
in curr_state table and if they match insert the row.  If they do not
match then update curr_state and insert a row into ping_log.  

I am not askng anybody to write it for me, I just want to know what is
the prefered PG method to do this.  Here is my table defs:
drop table pings;

create table pings (
cm_mac macaddr,
ts timestamp,
ping1 int4,
ping2 int4
primary key (cm_mac, ts) );

drop table curr_state ;

create table curr_state (
cm_mac macaddr primary key,
last_change,
up boolean
);

drop table ping_log ;

create table ping_log (
cm_mac macaddr,
ts timestamp,
state boolean,
primary key (cm_mac, ts)
);

Thanks 

marc



view thread (3+ messages)  latest in thread

Message-ID: <slrna1npu6.1s6p.marc@oscar.eng.cv.net>
Permalink:  ../slrna1npu6.1s6p.marc@oscar.eng.cv.net/
Also on:    postgresql.org/message-id/slrna1npu6.1s6p.marc@oscar.eng.cv.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: marc@oscar.eng.cv.net
  Subject: Re: should this be a trigger or a rule?
  In-Reply-To: <slrna1npu6.1s6p.marc@oscar.eng.cv.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox