Re: add constraints to views

From: Andreas Fromm <Andreas(dot)Fromm(at)physik(dot)uni-erlangen(dot)de>
To: List pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: add constraints to views
Date: 2003-09-20 14:02:28
Message-ID: 3F6C5DF4.10006@physik.uni-erlangen.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gaetano Mendola wrote:
| Andreas Fromm wrote:
|
|> CREATE VIEW test_view (
|> ~ SELECT * FROM test_table WHERE tag
|> );
|>
|> Now I want ad a NOT NULL constraint to the view on field1. I tryed the
|> following, but neither works.
|
|
| what does mean add a null constrain to a view ? Do you mean
| filter out the records with the field1 null ?
|
| CREATE OR REPLACE test_view AS
| SELECT *
| FROM test_table
| WHERE field1 IS NOT NULL AND
| tag;
|
No, I mean that the view behaves like a table with the same columns as
table, but that restricts to records on wich tag is set. To insert a
record to this "special" table it requires to have field1 set. In other
words: A record of table is a record of view if tag is set. If tag is
set, then field1 has also have to have a value. If tag is not set, it
may have a value for field1, but will not show up in the view. Of course
I could achive this be triggers, but I thought it could be possible to
do via constraints on the view.

Regards

Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Using GnuPG with Debian - http://enigmail.mozdev.org

iD8DBQE/bF30PkvkZVZzNY0RAqh8AJ0ZwagGrOhyuma/7gARKl1l35/wOACfVj9d
xYvyd2Pet25drqcv4vBE5eg=
=jXUQ
-----END PGP SIGNATURE-----

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message DN 2003-09-20 14:23:34 Question about connection java and Postgresql in Linux
Previous Message Richard Huxton 2003-09-20 13:25:17 Re: 'order by' does "wrong" with unicode-chars (german umlauts)