Assertion constraint replacement? - Mailing list pgsql-general

From Tille, Andreas
Subject Assertion constraint replacement?
Date
Msg-id Pine.LNX.4.44.0205161400330.8932-100000@wr-linux02.rki.ivbb.bund.de
Whole thread Raw
Responses Re: Assertion constraint replacement?
List pgsql-general
Hello,

sql-createtable.html says about CONSTRAINTS:

  CHECK (expression)

  CHECK clauses specify integrity constraints or tests which new or
  updated rows must satisfy for an insert or update operation to
  succeed. Each constraint must be an expression producing a Boolean
  result. A condition appearing within a column definition should
  reference that column's value only, while a condition appearing as
  a table constraint may reference multiple columns.

  Currently, CHECK expressions cannot contain subselects nor refer
  to variables other than columns of the current row.

But I want to add a constraint which has to check the value to insert
into a certain table column which has to be obtained from another
table under certain WHERE conditions (not just an index).


Going on reading sql-createtable.html:

  Assertions

  An assertion is a special type of integrity constraint and shares
  the same namespace as other constraints. However, an assertion is
  not necessarily dependent on one particular table as constraints
  are, so SQL92 provides the CREATE ASSERTION statement as an
  alternate method for defining a constraint:

  CREATE ASSERTION name CHECK ( condition )

  PostgreSQL does not implement assertions at present.

So Assertions might be the thing I'm looking for.  How can I implement a
kind of logic

      Accept value for column if it is contained in

         select SomeId from OtherTable where SomeOtherColumn = Value ;

Kind regards

         Andreas.

pgsql-general by date:

Previous
From: Jeff Eckermann
Date:
Subject: Re: Lexicographic index ?
Next
From: Doug Fields
Date:
Subject: Re: Is there eny e-mail server that uses postgreSQL