Skip site navigation (1) Skip section navigation (2)

Trying to Creat a Rule

From: "Madel, Kurt" <KMadel(at)USInspect(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Trying to Creat a Rule
Date: 2000-08-11 17:14:42
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql

I am trying to create a RULE that updates the size of a class when a student
registers for that class and the register(module) table is updated, and
subtract 1 from the given class size when a student drops a course.
Actually, there is a class table and a module table. The class table's
primary key is id, the module table consists of every module that a student
can register for a given year containing a class id. 

I think I have the INSERT RULE down, but am not sure about the UPDATE RULE: 

CREATE RULE module_update AS 
ON UPDATE TO module.a_q1 
SET class.size to class.size-1 
set class.size to class.size+1 

I am really not so sure about the 'and' part, but I need to do both updates
on class, using different WHERE criteria. 


pgsql-sql by date

Next:From: Zot O'ConnorDate: 2000-08-11 23:24:57
Subject: [Fwd: I will be at Linux World]
Previous:From: Mark VolpeDate: 2000-08-11 16:03:48
Subject: Re: Rules aren't doing what I expect

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group