pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Broersma Jr <rabroersma@yahoo.com>
To: General Postgresql List <pgsql-sql@postgresql.org>
Subject: Alternative to Select in table check constraint
Date: Fri, 30 Jun 2006 14:55:12 -0700 (PDT)
Message-ID: <20060630215512.18287.qmail@web31813.mail.mud.yahoo.com> (raw)

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))
);




view thread (11+ messages)  latest in thread

Message-ID: <20060630215512.18287.qmail@web31813.mail.mud.yahoo.com>
Permalink:  ../20060630215512.18287.qmail@web31813.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/20060630215512.18287.qmail@web31813.mail.mud.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rabroersma@yahoo.com
  Subject: Re: Alternative to Select in table check constraint
  In-Reply-To: <20060630215512.18287.qmail@web31813.mail.mud.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox