pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Madel, Kurt <KMadel@USInspect.com>
To: pgsql-sql@postgresql.org
Subject: Creating A Rule to Increment a class size when a student adds tha t class to their schedule
Date: Mon, 14 Aug 2000 16:40:09 -0400
Message-ID: <C6F9B91B745CD4119F1500A0C9DD60C02E3487@exchhq01.usinspect.com> (raw)

I am trying to create a rule that will increment the class.size in one table
when a student adds that class to their schedule in another table (module).
Basically, there are 3 tables involved:

class
module
student

When a student registers for their classes, the class.id is placed in its
respective module, the student.id is placed in module.student_id which is
combined with module.year to make up the primary key in the module table.

CREATE RULE class_size_increment_cq1 AS 
ON INSERT TO module.c_q1 
DO 
SET class.size to class.size+1 
WHERE class.id=module.c_q1;

This doesn't seem to be working.  Would it be just as fast or faster to use
a transaction:

begin;

insert into module.c_q1.....

update class set class.size to class.size+1 where class.id=module.c_q1;

commit;

TIF,
Kurt



Message-ID: <C6F9B91B745CD4119F1500A0C9DD60C02E3487@exchhq01.usinspect.com>
Permalink:  ../C6F9B91B745CD4119F1500A0C9DD60C02E3487@exchhq01.usinspect.com/
Also on:    postgresql.org/message-id/C6F9B91B745CD4119F1500A0C9DD60C02E3487@exchhq01.usinspect.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: KMadel@USInspect.com
  Subject: Re: Creating A Rule to Increment a class size when a student adds tha t class to their schedule
  In-Reply-To: <C6F9B91B745CD4119F1500A0C9DD60C02E3487@exchhq01.usinspect.com>
  References: <C6F9B91B745CD4119F1500A0C9DD60C02E3487@exchhq01.usinspect.com>

* 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