subselect in CHECK constraint?
От | Ian Turner |
---|---|
Тема | subselect in CHECK constraint? |
Дата | |
Msg-id | Pine.LNX.4.21.0009032145310.5371-100000@crafter.house обсуждение исходный текст |
Ответы |
Re: subselect in CHECK constraint?
RE: subselect in CHECK constraint? Re: subselect in CHECK constraint? |
Список | pgsql-general |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 When I try to do this: CREATE TABLE test ( a Integer, b Integer, CHECK ((SELECT SUM(t.a) FROM test t WHERE t.b = b) < 1000) ); INSERT INTO test (a, b) VALUES (100, 2); I get this error on the second query: ERROR: ExecEvalExpr: unknown expression type 108 I'm guessing this means I can't do subselects in CHECK statements. Let me pose another question, if this is the case: Say I have a table of warehouses. I then want to have another table keep track of the products at the warehouse, such that the amount of product at a warehouse does not exceed the capacity of the warehouse. Which probably means I would need to have a CHECK statement with a select on each side of the operator. Any ideas? :o I'd look at the source to see what this error means, except that I am on a dialup. Ian Turner -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE5syqYfn9ub9ZE1xoRAraCAKCFL7iMHuS62dyYlMMfY84FLG1LvQCgsUYi T3wCLoCqsojQ0WCDdkLjVPg= =tJoC -----END PGP SIGNATURE-----
В списке pgsql-general по дате отправления: