/**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_ADJUSTSHAREENTRY') 
 CREATE TABLE T_BCM_ADJUSTSHAREENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSHAREORGID BIGINT DEFAULT 0 NOT NULL,
FSHAREADJUSTID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ADJUSTCONVERTSET') 
 CREATE TABLE T_BCM_ADJUSTCONVERTSET (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FDEFAULTRATE VARCHAR(50) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUST' AND KSQL_COL_NAME ='FENTRYSOURCE') 
 ALTER TABLE T_BCM_RPTADJUST ADD (FENTRYSOURCE CHAR(1) DEFAULT '0' 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_RPTADJUST' AND KSQL_COL_NAME ='FCVTBEFORECURRENCYID') 
 ALTER TABLE T_BCM_RPTADJUST ADD (FCVTBEFORECURRENCYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUSTDATA' AND KSQL_COL_NAME ='FCVTBEFOREDEBIT') 
 ALTER TABLE T_BCM_RPTADJUSTDATA ADD (FCVTBEFOREDEBIT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUSTDATA' AND KSQL_COL_NAME ='FCVTBEFORECREDIT') 
 ALTER TABLE T_BCM_RPTADJUSTDATA ADD (FCVTBEFORECREDIT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUSTDATA' AND KSQL_COL_NAME ='FCVTBEFORESUMMONEY') 
 ALTER TABLE T_BCM_RPTADJUSTDATA ADD (FCVTBEFORESUMMONEY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUSTDATA' AND KSQL_COL_NAME ='FRATE') 
 ALTER TABLE T_BCM_RPTADJUSTDATA ADD (FRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
  

exec p_ModifyObjectName 'T_BCM_STRUCTOFENT', 'FDISABLERID', 'FSCHEMEID', 'COLUMN','BIGINT';
 
 /**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_constraint.sql **/