/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BASE_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_CUSTOMERRECORD_L') 
 CREATE TABLE T_BD_CUSTOMERRECORD_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FFORMERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_SUPPLIERRECORD_L') 
 CREATE TABLE T_BD_SUPPLIERRECORD_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FFORMERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_CUSTOMERRECORD') 
 CREATE TABLE T_BD_CUSTOMERRECORD (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FFORMERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORIGINATOR BIGINT DEFAULT 0 NOT NULL,
FCHANGEDATE DATETIME,
FEFFECTIME DATETIME,
FEXPIRYTIME DATETIME,
FSTATE CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BD_SUPPLIERRECORD') 
 CREATE TABLE T_BD_SUPPLIERRECORD (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FFORMERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FORIGINATOR BIGINT DEFAULT 0 NOT NULL,
FCHANGEDATE DATETIME,
FEFFECTIME DATETIME,
FEXPIRYTIME DATETIME,
FSTATE CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_SUPPLIER' AND KSQL_COL_NAME ='FEFFECTIVEDT') 
 ALTER TABLE T_BD_SUPPLIER ADD (FEFFECTIVEDT DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_SUPPLIER' AND KSQL_COL_NAME ='FEXPIRYDT') 
 ALTER TABLE T_BD_SUPPLIER ADD (FEXPIRYDT DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER' AND KSQL_COL_NAME ='FEFFECTIVEDT') 
 ALTER TABLE T_BD_CUSTOMER ADD (FEFFECTIVEDT DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BD_CUSTOMER' AND KSQL_COL_NAME ='FEXPIRYDT') 
 ALTER TABLE T_BD_CUSTOMER ADD (FEXPIRYDT DATETIME );

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