/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SRC_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_NEGOTIATE_CHG') 
 CREATE TABLE T_SRC_NEGOTIATE_CHG (
FID BIGINT DEFAULT 0 NOT NULL,
FPARENTID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FPENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FNEWSTOPBIDDATE DATETIME,
FNEGOTIATEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_APPLY' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_APPLY ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_APPLY' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_APPLY ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_EXPORT' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_EXPORT ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_EXPORT' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_EXPORT ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_INDEX ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_INDEX ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_DEMAND' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_DEMAND ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_DEMAND' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_DEMAND ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_EXPERTSCHEME' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_EXPERTSCHEME ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_EXPERTSCHEME' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_EXPERTSCHEME ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SUPSCHEME' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_SUPSCHEME ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SUPSCHEME' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_SUPSCHEME ADD (FLASTUPDATETIME DATETIME );
 EXEC p_AlterColumn 'T_SRC_VIE_DETAIL', 'FSUPPLIERIP', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_A' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_A ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_A' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_A ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_H' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_H ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_H' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_H ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_J' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_J ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_J' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_J ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_P' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_P ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_P' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_P ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_Q' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_Q ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_Q' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_Q ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_T' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_T ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_T' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_T ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_Z' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_Z ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_Z' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_Z ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_O' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_O ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_O' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_O ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PATTERN' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PATTERN ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PATTERN' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PATTERN ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SCHEME' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_SCHEME ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SCHEME' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_SCHEME ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_BIDCHANGE' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_BIDCHANGE ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_BIDCHANGE' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_BIDCHANGE ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_B' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_B ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_B' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_B ADD (FLASTUPDATETIME DATETIME );
 EXEC p_AlterColumn 'T_SRC_BIDDOCBILL', 'FISNOTICE', 'CHAR(1)', 'NOT NULL', '0001', '''0''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_BIDDOCBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_BIDDOCBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_BIDDOCBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_BIDDOCBILL ADD (FLASTUPDATETIME DATETIME );
 EXEC p_AlterColumn 'T_SRC_QUOTEBILL', 'FISNOTICE', 'CHAR(1)', 'NOT NULL', '0001', '''0''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_QUOTEBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_QUOTEBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_QUOTEBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_QUOTEBILL ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_Y' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_Y ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_Y' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_Y ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PRICECONFIRM' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PRICECONFIRM ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PRICECONFIRM' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PRICECONFIRM ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_C' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_C ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_C' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_C ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_X' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_X ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_X' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_X ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_E' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_E ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_E' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_E ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_F' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_F ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_F' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_F ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_K' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_PROJECT_K ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_K' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_PROJECT_K ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_NEGOTIATEBILL' AND KSQL_COL_NAME ='FLASTUPDATEUSERID') 
 ALTER TABLE T_SRC_NEGOTIATEBILL ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_NEGOTIATEBILL' AND KSQL_COL_NAME ='FLASTUPDATETIME') 
 ALTER TABLE T_SRC_NEGOTIATEBILL ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_NEGOTIATEBILL' AND KSQL_COL_NAME ='FISNOTICE') 
 ALTER TABLE T_SRC_NEGOTIATEBILL ADD (FISNOTICE CHAR(1) DEFAULT '0' NOT NULL );

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