Creating A Rule to Increment a class size when a student adds tha t class to their schedule

From: "Madel, Kurt" <KMadel(at)USInspect(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Creating A Rule to Increment a class size when a student adds tha t class to their schedule
Date: 2000-08-14 20:40:09
Message-ID: C6F9B91B745CD4119F1500A0C9DD60C02E3487@exchhq01.usinspect.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Browse pgsql-sql by date

  From Date Subject
Next Message Jesus Aneiros 2000-08-14 21:26:12 RE: select an entry with a NULL date field
Previous Message Adam Lang 2000-08-14 20:34:23 copy from