/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BOS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_INT_IDNUMBER') 
 CREATE TABLE T_INT_IDNUMBER (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(32) DEFAULT ' ' NOT NULL,
FCOUNTRY BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FSTATUS VARCHAR(1) DEFAULT 'A' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_INT_IDNUMBER_L') 
 CREATE TABLE T_INT_IDNUMBER_L (
FPKID VARCHAR(32) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(64) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(256) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_INT_IDNUMBERFORMAT') 
 CREATE TABLE T_INT_IDNUMBERFORMAT (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSERIALNO VARCHAR(32) DEFAULT ' ' NOT NULL,
FFORMATNAME NVARCHAR(128) DEFAULT ' ' NOT NULL,
FDISPLAYFORMAT VARCHAR(128) DEFAULT ' ' NOT NULL,
FREGULAREXPRESSION VARCHAR(256) DEFAULT ' ' NOT NULL
);

EXEC P_ALTERPK 'PK_T_INT_IDNUMBER', 'T_INT_IDNUMBER', 'FID', '1';

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


EXEC P_ALTERPK 'PK_T_INT_IDNUMBER_L', 'T_INT_IDNUMBER_L', 'FPKID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IDNUMBERFORMAT_L_NAME') CREATE INDEX IDX_IDNUMBERFORMAT_L_NAME ON T_INT_IDNUMBER_L ( FNAME );


EXEC P_ALTERPK 'PK_T_INT_IDNUMBERFORMAT', 'T_INT_IDNUMBERFORMAT', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_IDNUMBERFORMAT_FSERIALNO') CREATE INDEX IDX_IDNUMBERFORMAT_FSERIALNO ON T_INT_IDNUMBERFORMAT ( FSERIALNO );



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