Re: implement a referential integrity constraint (long)

From: --CELKO-- <>
Date: Fri, 8 May 2009 05:51:42 -0700 (PDT)
Message-ID: <>

>> This isn't the way I would have done it, ... <<

That is being kind :)

Try the "CHECK()-from-hell approach"

>> ..restricted to a list of countries in the world. <<

As opposed to those countries that are somewhere else? :)

 CONSTRAINT GenralAddressValidation
CHECK( CASE county_code

              WHEN  'xx'
              THEN (CASE WHEN line1 NOT LIKE ..THEN 'F'
                                    WHEN line2 NOT LIKE ..THEN 'F'
              WHEN  'yy'
              THEN (CASE WHEN line1 NOT LIKE ..THEN 'F'
                                    WHEN line NOT LIKE ..THEN 'F'
             .. ELSE 'T' END = 'T')

This is a pain to write, but the idea is to give each contry its own second level CASE expression. Received on Fri May 08 2009 - 14:51:42 CEST

Original text of this message