--
-- $Id$
--
-- Zet alle verwerkte contracten met nog openstaande facturen weer open

DEFINE thisfile = 'PCHD#40748.SQL'
DEFINE dbuser   = '^PCHD'
DEFINE custid   = 'PCHD'

SET ECHO ON
SET DEFINE ON
COLUMN fcltlogfile NEW_VALUE fcltlogfile NOPRINT;
WHENEVER SQLERROR EXIT;
SELECT adm.scriptspoolfile('&dbuser', '&thisfile') AS fcltlogfile FROM DUAL;
WHENEVER SQLERROR CONTINUE;
SPOOL &fcltlogfile
SET DEFINE OFF

UPDATE cnt_contract
   SET cnt_contract_status = 0
 WHERE cnt_contract_key IN (SELECT DISTINCT c.cnt_contract_key
                              FROM fin_factuur f, cnt_contract c
                             WHERE f.cnt_contract_key = c.cnt_contract_key
                               AND c.cnt_contract_status = 1
                               AND f.fin_factuur_statuses_key NOT IN (1, 7));

BEGIN adm.systrackscriptid('$Id$'); END;
/

COMMIT;

SPOOL OFF
