/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SYS_constraint.sql **/
 
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_IMPORTENTRY_TREE') 
 CREATE TABLE T_BAS_IMPORTENTRY_TREE (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPARENTENTRYID BIGINT DEFAULT 0 NOT NULL,
FFIELDKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FISIMPORT CHAR(1) DEFAULT ' ' NOT NULL,
FIMPORTPROP VARCHAR(50) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_IMPORTENTRYTEMPLATE') 
 CREATE TABLE T_BAS_IMPORTENTRYTEMPLATE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FTEMPLATETYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZOBJECT VARCHAR(50) DEFAULT ' ' NOT NULL,
FMULCOMBOFIELD CHAR(1) DEFAULT ' ' NOT NULL,
FMULCOMBO VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_IMPORTENTRYTEMPLATE_L') 
 CREATE TABLE T_BAS_IMPORTENTRYTEMPLATE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMMENT VARCHAR(255) DEFAULT ' ' NOT NULL
);

 EXEC P_ALTERPK 'PK_T_BAS_IMPORTENTRY_TREE', 'T_BAS_IMPORTENTRY_TREE', 'FENTRYID', '1';
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_BAS_IMPORTENTRY_TREE_FID') CREATE INDEX IDX_T_BAS_IMPORTENTRY_TREE_FID ON T_BAS_IMPORTENTRY_TREE ( FID );
 
 EXEC P_ALTERPK 'PK_T_BAS_IMPORTENTRYTEMPLATE', 'T_BAS_IMPORTENTRYTEMPLATE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_BAS_IMPORTENTRYTEMPLATE') CREATE INDEX IDX_T_BAS_IMPORTENTRYTEMPLATE ON T_BAS_IMPORTENTRYTEMPLATE ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_BAS_IMPORTENTRYTEMPLATE_L', 'T_BAS_IMPORTENTRYTEMPLATE_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_BAS_IMPORTENTRY_TPL_L') CREATE INDEX IDX_T_BAS_IMPORTENTRY_TPL_L ON T_BAS_IMPORTENTRYTEMPLATE_L ( FID );

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