-- Licensed Materials - Property of IBM
--
-- BI and PM: CM
--
-- (C) Copyright IBM Corp. 2008, 2009
--
-- US Government Users Restricted Rights - Use, duplication or disclosure
-- restricted by GSA ADP Schedule Contract with IBM Corp.

-- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
-- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).


CREATE TABLE CMOBJPROPS67 (
	CMID			int NOT NULL,
	NONPEAKDEMANDBGNH	int NULL,
	PEAKDEMANDBEGINH	int NULL,
	ASPEAKCONS		int NULL,
	BRSPEAKAFFINECONS	int NULL,
	BRSPEAKMAXPROCS		int NULL,
	BRSPEAKNONAFFCONS	int NULL,
	CMSPEAKCONS		int NULL,
	DDSPEAKCONS		int NULL,
	DISPEAKCONS		int NULL,
	DMSPEAKCONS		int NULL,
	DSPEAKCONS		int NULL,
	IDSPEAKCONS		int NULL,
	ISSPEAKCONS		int NULL,
	IUSPEAKCONS		int NULL,
	JSPEAKCONS		int NULL,
	MBSPEAKCONS		int NULL,			
	MISPEAKCONS		int NULL,
	MMSPEAKCONS		int NULL,
	PACSPEAKCONS		int NULL,
	PDSPEAKCONS		int NULL,
	PDSPEAKMAXPROCS		int NULL,
	PPSPEAKAFFINECONS	int NULL,
	PPSPEAKNONAFFCONS	int NULL,
	PRSPEAKCONS		int NULL,
	PTSPEAKCONS		int NULL,
	RSPEAKAFFINECONS	int NULL,
	RSPEAKMAXPROCS		int NULL,
	RSPEAKNONAFFCONS	int NULL,
	CONSTRAINT PK_CMOBJPROPS67 PRIMARY KEY (CMID) 
)

insert into CMOBJPROPS67(CMID) SELECT CMID FROM CMOBJECTS WHERE CLASSID IN (65, 4, 34, 47, 155, 177, 170, 171, 172, 176, 25, 199, 83, 84, 99, 88, 164, 165, 166, 186, 189, 191)

insert into CMOBJPROPS67 (CMID, NONPEAKDEMANDBGNH, PEAKDEMANDBEGINH) select o.PCMID, a.NEWNONPEAKBEGINHOUR, a.NEWPEAKBEGINHOUR from CMOBJECTS o left outer join CMOBJPROPS17 a on a.CMID = o.CMID where o.CLASSID = 92

insert into CMOBJPROPS67 (CMID) select CMID from CMOBJECTS where CLASSID = 14 and CMID not in (select CMID from CMOBJPROPS67)

update CMOBJPROPS67 set NONPEAKDEMANDBGNH = (select NEWNONPEAKBEGINHOUR from CMOBJPROPS17 where CMOBJPROPS67.CMID = CMID) where NONPEAKDEMANDBGNH is null

update CMOBJPROPS67 set PEAKDEMANDBEGINH = (select NEWPEAKBEGINHOUR from CMOBJPROPS17 where CMOBJPROPS67.CMID = CMID) where PEAKDEMANDBEGINH is null

!RunCMScript CMUpgradeScript_configuration_update_14.xml