[Q] TRIGGER-RULE

From: Max Buvry <Max(dot)Buvry(at)enseeiht(dot)fr>
To: pgsql-general(at)postgreSQL(dot)org
Subject: [Q] TRIGGER-RULE
Date: 1999-10-07 15:15:00
Message-ID: 199910071515.RAA24327@enseeiht.enseeiht.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I begin with Postgres and have a little problem to
define integrity constraint. I check the mailing-
lists archive but I don't find the answer exactly.

For example, I consider the following database :

CD(id_cd, author, title, id_owner)
OWNER(id_owner, name, tel)
BORROW(id_cd, id_owner)

At each insertion in BORROW, I want to check that
the two values id_cd and id_owner already exist
in CD and OWNER. Otherwise the insertion has not
to be executed.

First, is it better to use RULE or TRIGGER for that ?

I try to use RULE as following :

CREATE RULE r1 AS
ON INSERT TO borrow
WHERE new.id_cd NOT IN (SELECT id_cd FROM cd)
DO INSTEAD NOTHING;

When I execute this query, no problem. But when I
attempt to insert a new record in BORROW, an error
occurs : "ERROR : ExecEvalExpr:unknown expression type 108".
Do tou know what happened exactly ?

In advance, thank you for your response.

MB

Browse pgsql-general by date

  From Date Subject
Next Message Culberson, Philip 1999-10-07 16:11:29 Interesting group by behavior
Previous Message Matthias Urlichs 1999-10-07 14:41:28 Re: PostgreSQL vs Mysql comparison