/**Begin D:\d_desk\pdm\PDM_UPGRADE_1.1\PDM_UPGRADE\pdm1\BDM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BDM_ORG' AND KSQL_COL_NAME ='FENABLE') 
 ALTER TABLE T_BDM_ORG ADD (FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BDM_ORG' AND KSQL_COL_NAME ='FMASTERID') 
 ALTER TABLE T_BDM_ORG ADD (FMASTERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BDM_ORG' AND KSQL_COL_NAME ='FLEVEL') 
 ALTER TABLE T_BDM_ORG ADD (FLEVEL BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BDM_ORG' AND KSQL_COL_NAME ='FISLEAF') 
 ALTER TABLE T_BDM_ORG ADD (FISLEAF VARCHAR(10) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BDM_ORG_L') 
 CREATE TABLE T_BDM_ORG_L (
FPKID NVARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFULLNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTREENAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BDM_ORG_R3') 
 CREATE TABLE T_BDM_ORG_R3 (
FID BIGINT DEFAULT 0 NOT NULL,
FREFSTATUS CHAR(1) DEFAULT ' ' NOT NULL
);



/**End D:\d_desk\pdm\PDM_UPGRADE_1.1\PDM_UPGRADE\pdm1\BDM_table.sql **/
