/**Begin C:\PDM_UPGRADE\PDM1\SRM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CALRESULTENTITY' AND KSQL_COL_NAME IN ('FCATEGORYID')) 
 ALTER TABLE T_PUR_CALRESULTENTITY ADD (FCATEGORYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CALFORMULAENTITY' AND KSQL_COL_NAME IN ('FCATEGORYFIELD')) 
 ALTER TABLE T_PUR_CALFORMULAENTITY ADD (FCATEGORYFIELD VARCHAR(50) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CALFORMULAENTITY' AND KSQL_COL_NAME IN ('FDEFAULTRESULT')) 
 ALTER TABLE T_PUR_CALFORMULAENTITY ADD (FDEFAULTRESULT DECIMAL(23,10) DEFAULT -999999999 NOT NULL );
/**海信版本没有该字段 **/
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INDEXENTRY' AND KSQL_COL_NAME IN ('FACCORDANCE')) 
 ALTER TABLE T_PUR_INDEXENTRY ADD (FACCORDANCE VARCHAR(50) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_INDEXENTRY1SUB') 
 CREATE TABLE T_PUR_INDEXENTRY1SUB (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FITEM NVARCHAR(255) DEFAULT ' ' NOT NULL,
FVALUEFROM DECIMAL(19,6) DEFAULT 0 NOT NULL,
FVALUETO DECIMAL(19,6) DEFAULT 0 NOT NULL,
FITEMSCORE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FFORMULA VARCHAR(100) DEFAULT ' ' NOT NULL,
FVETO CHAR(1) DEFAULT ' ' NOT NULL,
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FACCORDANCE VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_INDEXENTRY1') 
 CREATE TABLE T_PUR_INDEXENTRY1 (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FISGENERICRULE CHAR(1) DEFAULT '1' NOT NULL,
FCATEGORYID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL
);



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