/**Begin D:\DBA\PDM_UPGRADE\PDM1\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPASCHEME' AND KSQL_COL_NAME IN ('FREPORTSTATUS')) 
 ALTER TABLE T_BCM_RPASCHEME ADD (FREPORTSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPASCHEME' AND KSQL_COL_NAME IN ('FUNATTENDEDTYPE')) 
 ALTER TABLE T_BCM_RPASCHEME ADD (FUNATTENDEDTYPE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPASCHEME' AND KSQL_COL_NAME IN ('FENTITYFLOWSTATUS')) 
 ALTER TABLE T_BCM_RPASCHEME ADD (FENTITYFLOWSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPASCHEME' AND KSQL_COL_NAME IN ('FCREATEINIFILE')) 
 ALTER TABLE T_BCM_RPASCHEME ADD (FCREATEINIFILE CHAR(1) DEFAULT '0' NOT NULL );
 EXEC p_AlterColumn 'T_BCM_RPAENTITYENTRY', 'FENTITYSCOPE', 'VARCHAR(50)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISRPASCHEMERULE') 
 CREATE TABLE T_BCM_ISRPASCHEMERULE (
FID BIGINT DEFAULT 0 NOT NULL,
FRPASCHEMEID BIGINT DEFAULT 0 NOT NULL,
FORDERNUM INT DEFAULT 0 NOT NULL,
FTYPE CHAR(1) DEFAULT '1' NOT NULL,
FCREATERID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FNAMECODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FFIXEDVALUE VARCHAR(50) DEFAULT ' ' NOT NULL,
FJOINSYMBOL VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_RPASCHEMETASK') 
 CREATE TABLE T_BCM_RPASCHEMETASK (
FPKID BIGINT DEFAULT 0 NOT NULL,
FRPASCHEMEID BIGINT DEFAULT 0 NOT NULL,
FTASKID BIGINT DEFAULT 0 NOT NULL,
FMODEID BIGINT DEFAULT 0 NOT NULL,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FYEARID BIGINT DEFAULT 0 NOT NULL,
FPERIODID BIGINT DEFAULT 0 NOT NULL,
FSTATUS CHAR(1) DEFAULT '3' NOT NULL,
FEXECUTIONROBOT VARCHAR(50) DEFAULT ' ' NOT NULL,
FNOTICE VARCHAR(255) DEFAULT ' ' NOT NULL,
FEXECUTIONTIME DATETIME,
FNOTICETIME DATETIME,
FENTITYID BIGINT DEFAULT 0 NOT NULL
);



/**End D:\DBA\PDM_UPGRADE\PDM1\BCM_table.sql **/
