pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedshould this be a trigger or a rule?
3+ messages / 2 participants
[nested] [flat]
* should this be a trigger or a rule?
@ 2001-12-16 00:16 Marc Spitzer <marc@oscar.eng.cv.net>
2001-12-16 02:04 ` Re: should this be a trigger or a rule? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: marc@oscar.eng.cv.net @ 2001-12-16 00:16 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: should this be a trigger or a rule?
2001-12-16 00:16 should this be a trigger or a rule? Marc Spitzer <marc@oscar.eng.cv.net>
@ 2001-12-16 02:04 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-12-16 02:25 ` Re: should this be a trigger or a rule? Marc Spitzer <marc@oscar.eng.cv.net>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2001-12-16 02:04 UTC (permalink / raw)
To: marc@oscar.eng.cv.net; +Cc: pgsql-sql
marc@oscar.eng.cv.net (Marc Spitzer) writes:
> 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.
Anything that's most naturally described as driven by insert (or update
or delete) of individual rows is best done as a trigger, IMHO.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: should this be a trigger or a rule?
2001-12-16 00:16 should this be a trigger or a rule? Marc Spitzer <marc@oscar.eng.cv.net>
2001-12-16 02:04 ` Re: should this be a trigger or a rule? Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-12-16 02:25 ` Marc Spitzer <marc@oscar.eng.cv.net>
0 siblings, 0 replies; 3+ messages in thread
From: Marc Spitzer @ 2001-12-16 02:25 UTC (permalink / raw)
To: pgsql-sql
On Sat, Dec 15, 2001 at 09:04:20PM -0500, Tom Lane wrote:
> marc@oscar.eng.cv.net (Marc Spitzer) writes:
> > 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.
>
> Anything that's most naturally described as driven by insert (or update
> or delete) of individual rows is best done as a trigger, IMHO.
>
> regards, tom lane
Thanks,
One last question, I am using Xemacs to auto format the code
for me, I have discovered the sql-postgres but that is only
in the postgres(psql) window not in the where I edit my code
window. I get this in lisp by using M-x load-library then ilisp
ams perl,tcl, C take care of them selves.
Thanks again,
marc
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2001-12-16 02:25 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-12-16 00:16 should this be a trigger or a rule? Marc Spitzer <marc@oscar.eng.cv.net>
2001-12-16 02:04 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-12-16 02:25 ` Marc Spitzer <marc@oscar.eng.cv.net>
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