From: | GB Clark <postgres(at)vsservices(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Constraint problems |
Date: | 2002-09-27 18:15:47 |
Message-ID: | 20020927131547.09ed1af2.postgres@vsservices.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hello,
I'm trying to create a constraint that will check to see if the inserted data is found
in another column in the table.
It could be that I'm going about this the wrong way, any clues for me?
Here is the present setup data for the table.
--SNIP--
--
--
--
DROP SEQUENCE sysusers_user_id_seq;
CREATE SEQUENCE sysusers_user_id_seq START 1000;
DROP TABLE sysusers;
CREATE TABLE sysusers (
user_id INTEGER DEFAULT nextval('sysusers_user_id_seq')
UNIQUE NOT NULL PRIMARY KEY,
username text NOT NULL UNIQUE,
password text NOT NULL,
createby text NOT NULL DEFAULT 'syscreate',
status char(1) DEFAULT 'A' CHECK (status in ('A', 'I')),
comment1 text,
comment2 text,
tstamp timestamp DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX username_unique_idx ON sysusers (username);
INSERT INTO sysusers (username, password, createby) VALUES ('syscreate', 'testing', 'syscreate');
ALTER TABLE sysusers ADD CONSTRAINT createby_test CHECK (createby in (username));
INSERT INTO sysusers (username, password) VALUES ('gclarkii', 'testing');
--SNIP--
It is the constraint on createby that I'm trying to get to work.
Thanks for any and all help.
GB
--
GB Clark II | Roaming FreeBSD Admin
gclarkii(at)VSServices(dot)COM | General Geek
CTHULU for President - Why choose the lesser of two evils?
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2002-09-27 18:29:34 | Re: Constraint problems |
Previous Message | Roland Roberts | 2002-09-27 17:29:03 | Re: [SQL] CURRENT_TIMESTAMP |