/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\PUR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SUPCATEGORY' AND KSQL_COL_NAME ='FORIGIN') 
 ALTER TABLE T_PUR_SUPCATEGORY ADD (FORIGIN CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_IMPROVE' AND KSQL_COL_NAME ='FFINISHSTATUS') 
 ALTER TABLE T_PUR_IMPROVE ADD (FFINISHSTATUS CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_IMPROVE' AND KSQL_COL_NAME ='FEXPECTDATE') 
 ALTER TABLE T_PUR_IMPROVE ADD (FEXPECTDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_IMPROVE' AND KSQL_COL_NAME ='FFINISHDATE') 
 ALTER TABLE T_PUR_IMPROVE ADD (FFINISHDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_EXTDATA' AND KSQL_COL_NAME ='FOBJECTID') 
 ALTER TABLE T_PUR_EXTDATA ADD (FOBJECTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_EXTTYPE' AND KSQL_COL_NAME ='FOBJECTID') 
 ALTER TABLE T_PUR_EXTTYPE ADD (FOBJECTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_INDEX_BIZTYPE') 
 CREATE TABLE T_PUR_INDEX_BIZTYPE (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_INDEX_CATEGORY') 
 CREATE TABLE T_PUR_INDEX_CATEGORY (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_INDEX_ORG') 
 CREATE TABLE T_PUR_INDEX_ORG (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INDEX' AND KSQL_COL_NAME ='FAPINAME') 
 ALTER TABLE T_PUR_INDEX ADD (FAPINAME VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INDEX' AND KSQL_COL_NAME ='FLEVEL') 
 ALTER TABLE T_PUR_INDEX ADD (FLEVEL INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INDEX' AND KSQL_COL_NAME ='FSOURCEID') 
 ALTER TABLE T_PUR_INDEX ADD (FSOURCEID BIGINT DEFAULT 0 NOT NULL );

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