problem with RULEs

From: Uros Gruber <uros(at)sir-mag(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: problem with RULEs
Date: 2002-05-03 16:53:07
Message-ID: 19330346736.20020503185307@sir-mag.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!

I don't know if this can be done with RULES or i have to use
FUNCTIONS.

I have table categories with colums

id,parent,name,cats

this is some data

1 | 0 | cat1 | 3
2 | 0 | cat2 | 1
11 | 1 | cat3 | 1
12 | 1 | cat4 | 0
21 | 2 | cat5 | 0
111 | 11 | cat6 | 0

cats colum mean how mani categories are inside some category,
U can see that cat1 have 3 sub cats, one is also sub ob
category cat3. This column is like totalsub category.

Now i want create rule on insert. When i create new category
i want that this cats would get automaticaly increased in all
required rows.

For example if i insert category

INSERT categories (id,parent,name,cats) VALUES (112,11,cat7,0)

I would like to increase by one in cat3 and also in cat1.

I've make some rule to increase oly parent category but where
i try create new rule to update all subs i have error msg

query rewritten 10 times, may contain cycles

I think i've done something wrong.

Can somebody help me with this. What RULE to apply or maybe
this have to be done with function

--
tia,
Uros mailto:uros(at)sir-mag(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joel Burton 2002-05-03 17:36:28 Re: problem with RULEs
Previous Message Scott Marlowe 2002-05-03 16:49:15 bool / vacuum full bug followup part 2