/** 对账中心扩展添加采购员等字段 Begin C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
-- 采购员
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RECEIPTENTRY' AND KSQL_COL_NAME IN ('FPURCHASER'))
ALTER TABLE T_PUR_RECEIPTENTRY ADD (FPURCHASER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INSTOCKENTRY' AND KSQL_COL_NAME IN ('FPURCHASER'))
ALTER TABLE T_PUR_INSTOCKENTRY ADD (FPURCHASER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RETURNENTRY' AND KSQL_COL_NAME IN ('FPURCHASER'))
ALTER TABLE T_PUR_RETURNENTRY ADD (FPURCHASER BIGINT DEFAULT 0 NOT NULL );

-- 跟踪号
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDERENTRY' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_ORDERENTRY ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SALOUTSTOCKENTRY' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_SALOUTSTOCKENTRY ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RECEIPTENTRY' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_RECEIPTENTRY ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INSTOCKENTRY' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_INSTOCKENTRY ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_REQUESTENTRY' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_REQUESTENTRY ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RETURNENTRY' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_RETURNENTRY ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECKENTRY2' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_CHECKENTRY2 ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_INVOICENTRY2 ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_INVOICENTRY ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECKENTRY' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_CHECKENTRY ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_PAYAPPLYENTRY' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_PAYAPPLYENTRY ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_PAYENTRY' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_PAYENTRY ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_DELIVERYSCHENTRY' AND KSQL_COL_NAME IN ('FTRACENO'))
ALTER TABLE T_PUR_DELIVERYSCHENTRY ADD (FTRACENO BIGINT DEFAULT 0 NOT NULL );




-- 配置号
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECKENTRY2' AND KSQL_COL_NAME IN ('FCONFIGUREDCODE'))
ALTER TABLE T_PUR_CHECKENTRY2 ADD (FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2' AND KSQL_COL_NAME IN ('FCONFIGUREDCODE'))
ALTER TABLE T_PUR_INVOICENTRY2 ADD (FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY' AND KSQL_COL_NAME IN ('FCONFIGUREDCODE'))
ALTER TABLE T_PUR_INVOICENTRY ADD (FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECKENTRY' AND KSQL_COL_NAME IN ('FCONFIGUREDCODE'))
ALTER TABLE T_PUR_CHECKENTRY ADD (FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_PAYAPPLYENTRY' AND KSQL_COL_NAME IN ('FCONFIGUREDCODE'))
ALTER TABLE T_PUR_PAYAPPLYENTRY ADD (FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_PAYENTRY' AND KSQL_COL_NAME IN ('FCONFIGUREDCODE'))
ALTER TABLE T_PUR_PAYENTRY ADD (FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_DELIVERYSCHENTRY' AND KSQL_COL_NAME IN ('FCONFIGUREDCODE'))
ALTER TABLE T_PUR_DELIVERYSCHENTRY ADD (FCONFIGUREDCODE BIGINT DEFAULT 0 NOT NULL );


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