Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Alternative to Select in table check constraint



I am practicing with SQL examples comming from the book:

JOE CELKO'S
SQL
PUZZLES
& ANSWERS

The following codes doesn't work on PostgreSQL 8.1.4 but according to the book does conform to
SQL-92.  Is there any other solutions that would result in the same effect?  Or is this an example
of a contraint that should be avoided at all costs?

CREATE TABLE BADGES
(
        BADGENO         SERIAL NOT NULL PRIMARY KEY,
        EMPNO           INTEGER NOT NULL REFERENCES SECEMPLOYEES (EMPNO),
        ISSUEDATE       DATE NOT NULL,
        STATUS          CHAR(1) NOT NULL CHECK ( STATUS IN ('A', 'I')),

        CHECK   ( 1 = ALL (     SELECT COUNT(STATUS)
                                FROM BADGES
                                WHERE STATUS = 'A'
                                GROUP BY EMPNO))
);




Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group