reference to a view - Mailing list pgsql-general

From Joolz
Subject reference to a view
Date
Msg-id 20040616084110.GA9018@localhost.localdomain
Whole thread Raw
Responses Re: reference to a view  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-general
In my db I have a table type_of_action, fields code varchar, name
varchar, medical boolean. Two other tables refer to this table, one of
them to the medical rows, the other one to the none-medical rows. I
would like to make the reference with a view, like this:

create table type of action_type (
  code varchar,
  name varchar,
  medical boolean
);

create view action_type_medical as select * from action_type
  where medical=true;
create view action_type_non_medical as select * from action_type
  where medical=false;

create table general_actions (
  field1, field2, field_etc,
  action_type varchar references action_type_non_medical(code)
);

create table medical_actions (
  field1, field2, field_etc,
  action_type varchar references action_type_medical(code)
);

But pg refuses this, can't create a reference to a view. I can now
create a trigger plus function that will do the check, but is there a
more elegant way? Thanks!

--
10:35-10:41
Fedora Core release 2 (Tettnang) Linux 2.6.6-1.435

pgsql-general by date:

Previous
From: Andrew Kelly
Date:
Subject: Re: how does license work for non-profit companies?
Next
From: Frank van Vugt
Date:
Subject: Re: Why is a union of two null-results automatically casted to type text ?