Обсуждение: rule question

Поиск
Список
Период
Сортировка

rule question

От
"Agrawal, Manish"
Дата:
Hi,

    This may be an inappropriate question for this list, but I have been
struggling with creating a rule in pgsql that will behave as follows:

    When I update a pledges table, if the pledge_amount is 0, the rule
should delete the row instead of recording the pledge as 0.

    I have created the following rule:

    CREATE RULE pledge_delete_zeros AS ON UPDATE TO pledges
    DELETE FROM pledges WHERE (new.pledge_amount = 0)

    The problem is that whenever I have any 0 pledge, the rule deletes
all rows in the table. Where am I going wrong?

Thanks
Manish
_________________________________
Manish Agrawal
Asstt. Prof., Dept. of ISDS, Univ. of South Florida
4202 E. Fowler Ave., CIS 1040, Tampa, Fl 33620 - 7800
(813)-974-6716 (W) 974-6749 (FAX)
magrawal@coba.usf.edu
______________________________________
I use Openoffice, the simple, free Office Suite for Windows/Linux/Macs that
works with existing documents. http://www.openoffice.org