

--
--    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.
--    


-------------------------------------------------------------------------------
-- NC31_UPDATE_ORA.SQL         *DO NOT EDIT*		Data Store Version: 31		 
-------------------------------------------------------------------------------

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

CREATE TABLE BC_NC_SCHEDULE(
   PK_SCHEDULE_ID                INTEGER NOT NULL,
   NAME                          VARCHAR2(255),
   DESCRIPTION                   VARCHAR2(1000),
   LASTMOD_BY                    CHAR(40),
   LASTMOD_TIME                  DATE DEFAULT sysdate NOT NULL,
   MODCOUNT                      INTEGER DEFAULT (-1),
   SCHEDULE_TYPE                 CHAR(6),
   TIMEZONE                      VARCHAR2(100),
   START_DATE                    NUMBER,
   END_DATE                      NUMBER,
   REPEAT_FOREVER                INTEGER,
   ACTIVE                        INTEGER,
   VALID_SCHEDULE                INTEGER,
   USE_DAY_NUMBER                INTEGER,
   DAY_OF_MONTH                  INTEGER,
   DAY_OF_WEEK                   INTEGER,
   DAY_OF_WEEK_IN_MONTH          INTEGER,
   MONTH_OF_YEAR                 INTEGER,
   REPEAT_INTERVAL               INTEGER,
   DAYS_OF_WEEK                  INTEGER,
   FIXED_INTERVAL_TYPE           INTEGER,
   FIXED_INTERVAL_IN_MILLIS      NUMBER(10),
   TRIGGER_ID                    VARCHAR2(255)
);

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

INSERT INTO BC_NC_SCHEDULE (
	PK_SCHEDULE_ID,NAME,DESCRIPTION,LASTMOD_BY,LASTMOD_TIME,MODCOUNT,
	SCHEDULE_TYPE,TIMEZONE,START_DATE,END_DATE,REPEAT_FOREVER,ACTIVE,
	VALID_SCHEDULE,USE_DAY_NUMBER,DAY_OF_MONTH,DAY_OF_WEEK,DAY_OF_WEEK_IN_MONTH,
	MONTH_OF_YEAR,REPEAT_INTERVAL,DAYS_OF_WEEK,FIXED_INTERVAL_TYPE,
	FIXED_INTERVAL_IN_MILLIS,TRIGGER_ID) 
SELECT PK_SCHEDULE_ID,NAME,DESCRIPTION,LASTMOD_BY,LASTMOD_TIME,MODCOUNT,
	SCHEDULE_TYPE,TIMEZONE,START_DATE,END_DATE,REPEAT_FOREVER,ACTIVE,
	VALID_SCHEDULE,USE_DAY_NUMBER,DAY_OF_MONTH,DAY_OF_WEEK,DAY_OF_WEEK_IN_MONTH,
	MONTH_OF_YEAR,REPEAT_INTERVAL,DAYS_OF_WEEK,FIXED_INTERVAL_TYPE,
	FIXED_INTERVAL_IN_MILLIS,TRIGGER_ID
FROM NC_SCHEDULE;

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


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

ALTER TABLE R_TASKSCHEDULE_SCHEDULE
   DROP CONSTRAINT F2R_TASKSCHEDULE_S;
   
ALTER TABLE NC_TASKSCHEDULE
   DROP CONSTRAINT F2N_TASKSCHEDULE;

DROP TABLE NC_SCHEDULE;

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

CREATE TABLE NC_SCHEDULE(
   PK_SCHEDULE_ID                INTEGER NOT NULL,
   NAME                          VARCHAR2(255),
   DESCRIPTION                   VARCHAR2(1000),
   LASTMOD_BY                    CHAR(40),
   LASTMOD_TIME                  DATE DEFAULT sysdate NOT NULL,
   MODCOUNT                      INTEGER DEFAULT (-1),
   SCHEDULE_TYPE                 CHAR(6),
   TIMEZONE                      VARCHAR2(100),
   START_DATE                    NUMBER,
   END_DATE                      NUMBER,
   REPEAT_FOREVER                INTEGER,
   ACTIVE                        INTEGER,
   VALID_SCHEDULE                INTEGER,
   USE_DAY_NUMBER                INTEGER,
   DAY_OF_MONTH                  INTEGER,
   DAY_OF_WEEK                   INTEGER,
   DAY_OF_WEEK_IN_MONTH          INTEGER,
   MONTH_OF_YEAR                 INTEGER,
   REPEAT_INTERVAL               INTEGER,
   DAYS_OF_WEEK                  INTEGER,
   FIXED_INTERVAL_TYPE           INTEGER,
   FIXED_INTERVAL_IN_MILLIS      NUMBER,
   TRIGGER_ID                    VARCHAR2(255)
);

-------------------------------------------------------------------------------
--$202-- indexes & primary keys add begin
-------------------------------------------------------------------------------

ALTER TABLE NC_SCHEDULE
   ADD (CONSTRAINT PN_SCHEDULE PRIMARY KEY (PK_SCHEDULE_ID));

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

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

INSERT INTO NC_DB_VERSION (DB_VERSION_ID,BUILD) VALUES(31,'build no.');
	   
-------------------------------------------------------------------------------
--$230-- restore inserts begin
-------------------------------------------------------------------------------

INSERT INTO NC_SCHEDULE (
	PK_SCHEDULE_ID,NAME,DESCRIPTION,LASTMOD_BY,LASTMOD_TIME,MODCOUNT,
	SCHEDULE_TYPE,TIMEZONE,START_DATE,END_DATE,REPEAT_FOREVER,ACTIVE,
	VALID_SCHEDULE,USE_DAY_NUMBER,DAY_OF_MONTH,DAY_OF_WEEK,DAY_OF_WEEK_IN_MONTH,
	MONTH_OF_YEAR,REPEAT_INTERVAL,DAYS_OF_WEEK,FIXED_INTERVAL_TYPE,
	FIXED_INTERVAL_IN_MILLIS,TRIGGER_ID) 
SELECT PK_SCHEDULE_ID,NAME,DESCRIPTION,LASTMOD_BY,LASTMOD_TIME,MODCOUNT,
	SCHEDULE_TYPE,TIMEZONE,START_DATE,END_DATE,REPEAT_FOREVER,ACTIVE,
	VALID_SCHEDULE,USE_DAY_NUMBER,DAY_OF_MONTH,DAY_OF_WEEK,DAY_OF_WEEK_IN_MONTH,
	MONTH_OF_YEAR,REPEAT_INTERVAL,DAYS_OF_WEEK,FIXED_INTERVAL_TYPE,
	FIXED_INTERVAL_IN_MILLIS,TRIGGER_ID
FROM BC_NC_SCHEDULE;

-------------------------------------------------------------------------------
--$240-- foreign keys add begin
-------------------------------------------------------------------------------

ALTER TABLE R_TASKSCHEDULE_SCHEDULE
   ADD (CONSTRAINT F2R_TASKSCHEDULE_S FOREIGN KEY (FK_SCHEDULE_ID)
      REFERENCES NC_SCHEDULE);
      
ALTER TABLE NC_TASKSCHEDULE
   ADD (CONSTRAINT F1N_TASKSCHEDULE FOREIGN KEY (FK_TASK_ID)
      REFERENCES NC_TASK);

-------------------------------------------------------------------------------
--$250-- backup drop begin
-------------------------------------------------------------------------------

DROP TABLE BC_NC_SCHEDULE;

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