

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


-------------------------------------------------------------------------------
-- NC315_UPDATE_DB2.SQL	       *DO NOT EDIT*		Data Store Version: 315		 
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$100-- backup create begin
-------------------------------------------------------------------------------

CREATE TABLE BC_NC_TS_CANCELLED_RUNS(
   FK_TASKSCHEDULE_ID 	 INTEGER NOT NULL,
   CANCELLED_DATE	 NUMERIC(19) NOT NULL,
   FK_SCHEDULE_ID        INTEGER,
   AUDIT_USER            VARCHAR(2000)
);

-------------------------------------------------------------------------------
--$110-- backup inserts begin
-------------------------------------------------------------------------------

INSERT INTO BC_NC_TS_CANCELLED_RUNS ( FK_TASKSCHEDULE_ID, CANCELLED_DATE, FK_SCHEDULE_ID, AUDIT_USER )
    SELECT FK_TASKSCHEDULE_ID, CANCELLED_DATE, FK_SCHEDULE_ID, AUDIT_USER FROM NC_TASKSCHEDULE_CANCELLED_RUNS;

-------------------------------------------------------------------------------
--$130-- views drop begin
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$140-- tables drop begin
-------------------------------------------------------------------------------

DROP TABLE NC_TASKSCHEDULE_CANCELLED_RUNS;

-------------------------------------------------------------------------------
--$200-- recreate tables begin
-------------------------------------------------------------------------------

CREATE TABLE NC_SCHEDULED_EVENT_OVERRIDE (
   FK_TASKSCHEDULE_ID 	 	INTEGER NOT NULL,
   EVENT_DATE	 		NUMERIC(19) NOT NULL,
   EVENT_STATUS              	INTEGER,
   EVENT_PRIORITY               INTEGER,
   FK_SCHEDULE_ID        	INTEGER,
   CANCELLED_BY            	VARCHAR(2000)
);

-------------------------------------------------------------------------------
--$201-- indices create begin
-------------------------------------------------------------------------------

CREATE INDEX I1N_EVENT_DATES ON NC_SCHEDULED_EVENT_OVERRIDE (FK_TASKSCHEDULE_ID);

-------------------------------------------------------------------------------
--$202-- primary keys add begin
-------------------------------------------------------------------------------

ALTER TABLE NC_SCHEDULED_EVENT_OVERRIDE
	ADD CONSTRAINT PN_EVENT_DATES PRIMARY KEY (FK_TASKSCHEDULE_ID, EVENT_DATE);

-------------------------------------------------------------------------------
--$203-- alter tables begin
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$210-- views create begin
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$220-- server data inserts begin
-------------------------------------------------------------------------------

INSERT INTO NC_DB_VERSION (DB_VERSION_ID,BUILD) VALUES(315,'build no.');

 -------------------------------------------------------------------------------
 --$230-- restore inserts begin
 -------------------------------------------------------------------------------
 
INSERT INTO NC_SCHEDULED_EVENT_OVERRIDE ( FK_TASKSCHEDULE_ID, EVENT_DATE, FK_SCHEDULE_ID, CANCELLED_BY )
    SELECT FK_TASKSCHEDULE_ID, CANCELLED_DATE, FK_SCHEDULE_ID, AUDIT_USER FROM BC_NC_TS_CANCELLED_RUNS;

 -------------------------------------------------------------------------------
 --$250-- backup drop begin
 -------------------------------------------------------------------------------
 
DROP TABLE BC_NC_TS_CANCELLED_RUNS;

-------------------------------------------------------------------------------
--$260-- end sql by function
-------------------------------------------------------------------------------
--	END NC315_UPDATE_DB2.SQL			*	DO NOT EDIT	 * 		 
-------------------------------------------------------------------------------
