/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_BIZRULE' AND KSQL_COL_NAME ='FPRIORITY') 
 ALTER TABLE T_BCM_BIZRULE ADD (FPRIORITY NVARCHAR(2) DEFAULT '1' NOT NULL );
 EXEC p_AlterColumn 'T_BCM_MEMBOFACCOUNT_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_REPORTLIST', 'FPROCESS', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_BIZRULE_L', 'FNAME', 'NVARCHAR(500)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_BIZRULECATALOG_L', 'FNAME', 'NVARCHAR(500)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_BIZRULEVERSION_L', 'FNAME', 'NVARCHAR(500)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_CONFIGSETTING', 'FNAME', 'NVARCHAR(1000)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_CONFIGSETTING', 'FDESCRIPTIOIN', 'NVARCHAR(2000)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_TEMPLATECATALOG_L', 'FNAME', 'NVARCHAR(500)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_TEMPLATE', 'FNAME', 'NVARCHAR(500)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TEMPLATE' AND KSQL_COL_NAME ='FVERSIONDESCRIPTION') 
 ALTER TABLE T_BCM_TEMPLATE ADD (FVERSIONDESCRIPTION VARCHAR(500) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TEMPLATE' AND KSQL_COL_NAME ='FEXPIRINGDATE') 
 ALTER TABLE T_BCM_TEMPLATE ADD (FEXPIRINGDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TEMPLATE' AND KSQL_COL_NAME ='FSTATUS') 
 ALTER TABLE T_BCM_TEMPLATE ADD (FSTATUS CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_TEMPLATE_L') 
 CREATE TABLE T_BCM_TEMPLATE_L (
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(20) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(500) DEFAULT ' ' NOT NULL,
FEDITDESCRIPTION NCLOB,
FVERSIONDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL
);


 EXEC p_AlterColumn 'T_BCM_TASKCATALOG_L', 'FNAME', 'NVARCHAR(500)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CHKEFFECTIVE') 
 CREATE TABLE T_BCM_CHKEFFECTIVE (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FEFFECTIVEYEAR BIGINT DEFAULT 0 NOT NULL,
FEFFECTIVEPERIOD BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CONDIFFEFFECTIVE') 
 CREATE TABLE T_BCM_CONDIFFEFFECTIVE (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FEFFECTIVEYEAR BIGINT DEFAULT 0 NOT NULL,
FEFFECTIVEPERIOD BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_LINKAGEEFFECTIVE') 
 CREATE TABLE T_BCM_LINKAGEEFFECTIVE (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FEFFECTIVEYEAR BIGINT DEFAULT 0 NOT NULL,
FEFFECTIVEPERIOD BIGINT DEFAULT 0 NOT NULL
);



/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
