/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\ER_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_TRIP_CARREGULATION') 
 CREATE TABLE T_ER_TRIP_CARREGULATION (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(200) DEFAULT ' ' NOT NULL,
FISAPPROVE CHAR(1) DEFAULT '0' NOT NULL,
FISUSEQUOTA CHAR(1) DEFAULT '0' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


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

 EXEC P_ALTERPK 'PK_T_ER_TRIP_CARREGULATION', 'T_ER_TRIP_CARREGULATION', 'FID', '1';

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


 EXEC P_ALTERPK 'PK_ER_TRIP_CARREGULATION_L', 'T_ER_TRIP_CARREGULATION_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TRIP_CARREGULATION_L_ID') CREATE INDEX IDX_TRIP_CARREGULATION_L_ID ON T_ER_TRIP_CARREGULATION_L ( FID ,FLOCALEID );

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