Subject: a question on rules...

From: Xinguo Wei <[email-masked]>
Date: Mon, 16 Jan 1995 17:02:46 -0800 (PST)

Hi,

Say, I have two classes as defined below.

create emp (name = text, dept_name = text, age = int4) \g
create dept (name = text, members = setof emp) \g

I can append the dept class by the following postquel commands:

append dept (name = "toy", members = "retrieve (emp.all)
             where emp.dept_name = \\"toy\\"") \g
append dept (name = "shoe", members = "retrieve (emp.all)
             where emp.dept_name = \\"shoe\\"") \g
....

Noticing the same pattern on the declaration on members, I decided to 
create a rule on the append:

define function get_mem (language = "postquel", returntype = setof emp)
  arg is (text) as "retrieve (emp.all) where emp.dept_name = $1" \g
define rule get_mem_rule is on append to dept
  do replace new(members = get_mem(new.name)) \g

But, I got the following message from postgres when appending dept:

append dept(name = "toy")\g
Query sent to backend is "append dept(name = "toy")"
WARN:Jan 16 16:57:27:planAction has more than 1 items!

What is the problem here?

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "[email-masked]".
   If this fails, send mail to "[email-masked]" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================
              URL: http://s2k-ftp.CS.Berkeley.EDU:8000/postgres/