| From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
|---|---|
| To: | cliff(at)cliffmeyers(dot)com |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: help with table constraint / check |
| Date: | 2003-03-15 16:29:54 |
| Message-ID: | 20030315162954.GA17488@wolff.to |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Sat, Mar 15, 2003 at 07:38:20 -0800,
cliff(at)cliffmeyers(dot)com wrote:
>
> What I want to do is set up a constraint / check so that when a record is added,
> it takes the parent_id being passed in the INSERT statement, looks at the record
> whose fs_id equals the parent_id, and makes sure that the fs_type for that record
> is 'dir' and not 'file'.
>
> Can I do this with standard constraints or do I need to use some PL/pgSQL
> features? Anyone have a few hints? Thanks!
One way to do this is to add a column with the parent's file system
type (constrained to be 'dir') and then make the foreign key to the parent use
both the parent ID and the file system type.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joost Witteveen | 2003-03-15 23:53:32 | create index right after create table not working? |
| Previous Message | cliff | 2003-03-15 15:38:20 | help with table constraint / check |