/*ORDER 502343*/      

ALTER TABLE CUSTOMER ADD (CONTRACTUSAGE  NUMBER DEFAULT 0 NOT NULL
                                         CONSTRAINT ContractUsage_Valid
                                                CHECK (CONTRACTUSAGE IN (0,
     1)));

COMMENT ON COLUMN CUSTOMER.CONTRACTUSAGE IS '0 = Single customer contract
1 = Predefined contract';

UPDATE CUSTOMER C SET CONTRACTUSAGE =
(case when exists ( select 1 from contractcustomer cc where cc.customer_link_id = c.customer_id )
      then 1
      else 0
 end);
 


