Conditional SQLite check constraint?
        Posted  
        
            by Rezzie
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Rezzie
        
        
        
        Published on 2010-04-10T23:48:34Z
        Indexed on 
            2010/04/10
            23:53 UTC
        
        
        Read the original article
        Hit count: 352
        
I have a table defined by the following SQL:
CREATE TABLE test (
  id       integer PRIMARY KEY NOT NULL UNIQUE,
  status   text NOT NULL,
  enddate  date,
  /* Checks */
  CHECK (status IN ("Current", "Complete"))
);
I'd like to add a constraint that requires enddate to be non-null if the status is "Complete".
Is this possible? I am using SQLite v3.6.16.
© Stack Overflow or respective owner