/**Begin C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDER' AND KSQL_COL_NAME IN ('FBUSINESSTYPEID')) 
 ALTER TABLE T_PUR_ORDER ADD (FBUSINESSTYPEID 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 ('FLINETYPEID')) 
 ALTER TABLE T_PUR_ORDERENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SALOUTSTOCK' AND KSQL_COL_NAME IN ('FBUSINESSTYPEID')) 
 ALTER TABLE T_PUR_SALOUTSTOCK ADD (FBUSINESSTYPEID 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 ('FLINETYPEID')) 
 ALTER TABLE T_PUR_SALOUTSTOCKENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDCHANGE' AND KSQL_COL_NAME IN ('FBUSINESSTYPEID')) 
 ALTER TABLE T_PUR_ORDCHANGE ADD (FBUSINESSTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDCHANGENTRY' AND KSQL_COL_NAME IN ('FLINETYPEID')) 
 ALTER TABLE T_PUR_ORDCHANGENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RECEIPT' AND KSQL_COL_NAME IN ('FBUSINESSTYPEID')) 
 ALTER TABLE T_PUR_RECEIPT ADD (FBUSINESSTYPEID 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 ('FLINETYPEID')) 
 ALTER TABLE T_PUR_RECEIPTENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INSTOCK' AND KSQL_COL_NAME IN ('FBUSINESSTYPEID')) 
 ALTER TABLE T_PUR_INSTOCK ADD (FBUSINESSTYPEID 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 ('FLINETYPEID')) 
 ALTER TABLE T_PUR_INSTOCKENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_REQUEST' AND KSQL_COL_NAME IN ('FBUSINESSTYPEID')) 
 ALTER TABLE T_PUR_REQUEST ADD (FBUSINESSTYPEID 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 ('FLINETYPEID')) 
 ALTER TABLE T_PUR_REQUESTENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RETURN' AND KSQL_COL_NAME IN ('FBUSINESSTYPEID')) 
 ALTER TABLE T_PUR_RETURN ADD (FBUSINESSTYPEID 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 ('FLINETYPEID')) 
 ALTER TABLE T_PUR_RETURNENTRY ADD (FLINETYPEID 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 ('FLINETYPEID')) 
 ALTER TABLE T_PUR_CHECKENTRY2 ADD (FLINETYPEID 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 ('FLINETYPEID')) 
 ALTER TABLE T_PUR_CHECKENTRY ADD (FLINETYPEID 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 ('FLINETYPEID')) 
 ALTER TABLE T_PUR_INVOICENTRY2 ADD (FLINETYPEID 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 ('FLINETYPEID')) 
 ALTER TABLE T_PUR_INVOICENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDERCHECK' AND KSQL_COL_NAME IN ('FLINETYPEID')) 
 ALTER TABLE T_PUR_ORDERCHECK ADD (FLINETYPEID 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 ('FLINETYPEID')) 
 ALTER TABLE T_PUR_PAYAPPLYENTRY ADD (FLINETYPEID BIGINT DEFAULT 0 NOT NULL );
 
 
/**End C:\PDM_UPGRADE\PDM1\PUR_table.sql **/