problem with check constraint using a select command.

From: "George Henson" <george(at)tcinet(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: problem with check constraint using a select command.
Date: 2000-07-24 19:03:55
Message-ID: 010901bff5a1$ea11d440$d000a8c0@safe.tcinet.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)tcinet(dot)net

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dave Smith 2000-07-24 19:07:55 Only updating part of a column
Previous Message bmccoy 2000-07-24 17:54:52 Re: Web front-end