/**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_CSLSCHEME') 
 CREATE TABLE T_BCM_CSLSCHEME (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(80) DEFAULT ' ' NOT NULL,
FISENABLE CHAR(1) DEFAULT '1' NOT NULL,
FNODETYPE CHAR(1) DEFAULT '1' NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FLONGNUMBER VARCHAR(100) DEFAULT ' ' NOT NULL,
FISLEAF CHAR(1) DEFAULT '1' NOT NULL,
FLEVEL INT DEFAULT 0 NOT NULL,
FMODEL BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CSLSCHEME_L') 
 CREATE TABLE T_BCM_CSLSCHEME_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,
FDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFENT' AND KSQL_COL_NAME ='FSHOWNUMBER') 
 ALTER TABLE T_BCM_STRUCTOFENT ADD (FSHOWNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL );
--exec p_ModifyObjectName 'T_BCM_STRUCTOFENT', 'FSIMPLENAME', 'FSHOWNUMBER', 'COLUMN','NVARCHAR(50)';

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