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

Поиск
Список
Период
Сортировка
От Madel, Kurt
Тема Creating A Rule to Increment a class size when a student adds tha t class to their schedule
Дата
Msg-id C6F9B91B745CD4119F1500A0C9DD60C02E3487@exchhq01.usinspect.com
обсуждение исходный текст
Список 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


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Adam Lang"
Дата:
Сообщение: copy from
Следующее
От: Jesus Aneiros
Дата:
Сообщение: RE: select an entry with a NULL date field