problem with check constraint using a select command. - Mailing list pgsql-general

From George Henson
Subject problem with check constraint using a select command.
Date
Msg-id 010901bff5a1$ea11d440$d000a8c0@safe.tcinet.net
Whole thread Raw
List pgsql-general
I am running PostgreSQL v 7.0.2 on Linux 2.0.36

I have a table that holds definitions of objects. I have a second table to
hold the instances of these objects ( and the current values)

I would like to insure the instances are valid master object types.

I started using a check constraint on the columns but I got a ExecEvalExpr:
unknown expression type 108
 error.

My table definitions and data inserts are below.

Thank you

create table master_objects (
  obj_type_html varchar(32),
  obj_lang      varchar(2),
  obj_type_lang varchar(50),
  obj_comment   varchar(200),
  constraint master_objects_pk primary key (obj_type_html, obj_lang)
);

create table instance_object (
  object_id     char(32),
  obj_type_html varchar(32),
  obj_lang      varchar(2),
  object_parent char(32),
  display_order int,
  constraint instance_object_pk primary key (object_id),
  constraint instance_object_fk foreign key (object_parent)
    references instance_object (object_id),
  constraint instance_object_obj_type_html_ck check (obj_type_html in
    (select distinct obj_type_html from master_objects)),
  constraint instance_object_obj_lang_ck check (obj_lang in
    (select distinct obj_lang from master_objects))
);

insert into master_objects
  (obj_type_html, obj_lang, obj_type_lang, obj_comment)
    values
  ('image', 'EN', 'Image', 'This is an image')
;

insert into instance_object
  (object_id, object_parent)
    values
  ('image', 'EN')
;



--
George Henson
george@tcinet.net


pgsql-general by date:

Previous
From: Gilles DAROLD
Date:
Subject: Re: Web front-end
Next
From: Dave Smith
Date:
Subject: Only updating part of a column