Re: [GENERAL] sub query constraint

2005-03-29 Thread Dale Sykora
Yudie Pg wrote: CREATE OR REPLACE FUNCTION validate_actions_insert() RETRUNS OPAQUE AS ' CREATE OR REPLACE FUNCTION validate_actions_insert() RETURNS OPAQUE AS $$ DECLARE rs RECORD; BEGIN SELECT INTO rs * FROM user_data WHERE name = NEW.user and write_access = 't'; IF NOT FOUND THEN RA

Re: [GENERAL] sub query constraint

2005-03-29 Thread Dale Sykora
Yudie Pg wrote: One way to do this is to add a write_access column to actions and use a constraint to force it to be true. Create a UNIQUE key of (name, write_access) for user_data and then add a FOREIGN KEY reference from (name, write_access) in actions to (name, write_access) in user_data. Yes

Re: [GENERAL] sub query constraint

2005-03-28 Thread Yudie Pg
> One way to do this is to add a write_access column to actions and use > a constraint to force it to be true. >Create a UNIQUE key of > (name, write_access) for user_data and then add a FOREIGN KEY > reference from (name, write_access) in actions to (name, write_access) > in user_data. Yes the

Re: [GENERAL] sub query constraint

2005-03-28 Thread Bruno Wolff III
On Mon, Mar 28, 2005 at 16:13:59 -0600, Dale Sykora <[EMAIL PROTECTED]> wrote: > > CREATE TABLE user_data( > name varchar(32), > write_access bool DEFAULT 'f' > ); > CREATE TABLE actions( > action varchar(32), > user varchar(32) -- somehow make sure user = user_data.name

[GENERAL] sub query constraint

2005-03-28 Thread Dale Sykora
I am trying to develop a database table column that is contrainted to a subset of another table column. I have tried using foreign key, check, and inheritance, but I cannot figure out how to do it. I have a user_data table that has various user columns including name and the bool column writ