/**Begin C:\PDM_UPGRADE\PDM1\SRM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_TEMPAPPROVE') 
 CREATE TABLE T_PUR_TEMPAPPROVE (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBIZTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FCFMSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FBILLDATE DATETIME,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FBDSUPPLIER BIGINT DEFAULT 0 NOT NULL,
FEXPIRYDATE DATETIME,
FAPPLYDATE DATETIME,
FREMAINDATE INT DEFAULT 0 NOT NULL,
FAPPLYREASON NVARCHAR(512) DEFAULT ' ' NOT NULL,
FTEMPSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
);


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


/**End C:\PDM_UPGRADE\PDM1\SRM_table.sql **/


/**Begin C:\PDM_UPGRADE\PDM1\SRM_constraint.sql **/
 EXEC P_ALTERPK 'PK_T_PUR_TEMPAPPROVE', 'T_PUR_TEMPAPPROVE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_TEMPAPPROVE_BILLNO') CREATE INDEX IDX_PUR_TEMPAPPROVE_BILLNO ON T_PUR_TEMPAPPROVE ( FBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_TEMPAPPROVE_ORG') CREATE INDEX IDX_PUR_TEMPAPPROVE_ORG ON T_PUR_TEMPAPPROVE ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_PUR_TEMPAPPROVE_SUPP') CREATE INDEX IDX_PUR_TEMPAPPROVE_SUPP ON T_PUR_TEMPAPPROVE ( FSUPPLIERID );


 EXEC P_ALTERPK 'PK_T_PUR_TEMPAPPROVE_L', 'T_PUR_TEMPAPPROVE_L', 'FPKID', '1';

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



/**End C:\PDM_UPGRADE\PDM1\SRM_constraint.sql **/

