/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\POM_table.sql **/
-- 采购入库单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURINBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_PURINBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURINBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_PURINBILL ADD (FLASTUPDATETIME DATETIME );

-- 采购收货单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_PURRECBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_PURRECBILL ADD (FLASTUPDATETIME DATETIME );

-- 其他入库单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHERINBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_OTHERINBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHERINBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_OTHERINBILL ADD (FLASTUPDATETIME DATETIME );

-- 生产入库单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PRODUCTINBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_PRODUCTINBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PRODUCTINBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_PRODUCTINBILL ADD (FLASTUPDATETIME DATETIME );

-- 销售出库单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_SALOUTBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_SALOUTBILL ADD (FLASTUPDATETIME DATETIME );

-- 领料申请单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_MREQBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_MREQBILL ADD (FLASTUPDATETIME DATETIME );

-- 领料出库单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_MREQOUTBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MREQOUTBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_MREQOUTBILL ADD (FLASTUPDATETIME DATETIME );

-- 其他出库单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHEROUTBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_OTHEROUTBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHEROUTBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_OTHEROUTBILL ADD (FLASTUPDATETIME DATETIME );

-- 调拨申请单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSAPPLY' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_TRANSAPPLY ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSAPPLY' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_TRANSAPPLY ADD (FLASTUPDATETIME DATETIME );

-- 直接调拨单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_TRANSDIRBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_TRANSDIRBILL ADD (FLASTUPDATETIME DATETIME );

-- 分步调出单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSOUTBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_TRANSOUTBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSOUTBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_TRANSOUTBILL ADD (FLASTUPDATETIME DATETIME );

-- 分步调入单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSINBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_TRANSINBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSINBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_TRANSINBILL ADD (FLASTUPDATETIME DATETIME );

-- 仓位移动单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_LOCATIONTRANSFER' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_LOCATIONTRANSFER ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_LOCATIONTRANSFER' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_LOCATIONTRANSFER ADD (FLASTUPDATETIME DATETIME );

-- 形态转换单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ADJUSTBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_ADJUSTBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ADJUSTBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_ADJUSTBILL ADD (FLASTUPDATETIME DATETIME );

-- 组装单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ASSEMBBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_ASSEMBBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_ASSEMBBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_ASSEMBBILL ADD (FLASTUPDATETIME DATETIME );

-- 拆卸单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_DISASSEMBLEBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_DISASSEMBLEBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_DISASSEMBLEBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_DISASSEMBLEBILL ADD (FLASTUPDATETIME DATETIME );

-- 盘点方案
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INVCOUNTSCHEME' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_INVCOUNTSCHEME ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INVCOUNTSCHEME' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_INVCOUNTSCHEME ADD (FLASTUPDATETIME DATETIME );

-- 盘点表
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INVCOUNTBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_INVCOUNTBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INVCOUNTBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_INVCOUNTBILL ADD (FLASTUPDATETIME DATETIME );

-- 初始库存单
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INITBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID')
ALTER TABLE T_IM_INITBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INITBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME')
ALTER TABLE T_IM_INITBILL ADD (FLASTUPDATETIME DATETIME );

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

