/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_AJSGLOBALSETTING') 
 CREATE TABLE T_BCM_AJSGLOBALSETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FSOURCEORGID BIGINT DEFAULT 0 NOT NULL,
FSHAREORGID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENARIO NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FAUDITTRIAL NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FFYEAR NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FPERIOD NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FBUSINESSTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFYDATE DATETIME
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUST' AND KSQL_COL_NAME ='FALLSHAREORG') 
 ALTER TABLE T_BCM_RPTADJUST ADD (FALLSHAREORG NVARCHAR(500) DEFAULT ' ' NOT NULL );
 
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_USERSELECT' AND KSQL_COL_NAME ='FCSLSCHEME') 
 ALTER TABLE T_BCM_USERSELECT ADD (FCSLSCHEME BIGINT DEFAULT 0 NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CSLSCHEME' AND KSQL_COL_NAME ='FCREATER') 
 ALTER TABLE T_BCM_CSLSCHEME ADD (FCREATER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CSLSCHEME' AND KSQL_COL_NAME ='FMODIFIER') 
 ALTER TABLE T_BCM_CSLSCHEME ADD (FMODIFIER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CSLSCHEME' AND KSQL_COL_NAME ='FCREATEDATE') 
 ALTER TABLE T_BCM_CSLSCHEME ADD (FCREATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CSLSCHEME' AND KSQL_COL_NAME ='FMODIFYDATE') 
 ALTER TABLE T_BCM_CSLSCHEME ADD (FMODIFYDATE DATETIME );

 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CSLSCHEME' AND KSQL_COL_NAME ='FEFFECTIVEDATE') 
 ALTER TABLE T_BCM_CSLSCHEME ADD (FEFFECTIVEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CSLSCHEME' AND KSQL_COL_NAME ='FEXPIRATIONDATE') 
 ALTER TABLE T_BCM_CSLSCHEME ADD (FEXPIRATIONDATE DATETIME );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CSLSCHEME' AND KSQL_COL_NAME ='FISLEGALORGVIEW') 
 ALTER TABLE T_BCM_CSLSCHEME ADD (FISLEGALORGVIEW CHAR(1) DEFAULT '0' NOT NULL );
  IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CSLSCHEME' AND KSQL_COL_NAME ='FEFFECTIVESTATUS') 
 ALTER TABLE T_BCM_CSLSCHEME ADD (FEFFECTIVESTATUS CHAR(1) DEFAULT '0' NOT NULL );
   IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CSLSCHEME' AND KSQL_COL_NAME ='FVERSION') 
 ALTER TABLE T_BCM_CSLSCHEME ADD (FVERSION INT DEFAULT 0 NOT NULL );

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