/**Begin C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECKENTRY' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_CHECKENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SALOUTSTOCK' AND KSQL_COL_NAME IN ('FTARBILLTYPE')) 
 ALTER TABLE T_PUR_SALOUTSTOCK ADD (FTARBILLTYPE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDCHANGENTRY_A' AND KSQL_COL_NAME IN ('FISCONTROLAMOUNTUP')) 
 ALTER TABLE T_PUR_ORDCHANGENTRY_A ADD (FISCONTROLAMOUNTUP CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDCHANGENTRY_A' AND KSQL_COL_NAME IN ('FAMOUNTUP')) 
 ALTER TABLE T_PUR_ORDCHANGENTRY_A ADD (FAMOUNTUP DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INSTOCKENTRY' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_INSTOCKENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RECEIPTENTRY' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_RECEIPTENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDERCHECK' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_ORDERCHECK ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_INVOICENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDERENTRY' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_ORDERENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDCHANGENTRY' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_ORDCHANGENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_REQUESTENTRY' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_REQUESTENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RETURNENTRY' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_RETURNENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SALOUTSTOCKENTRY' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_SALOUTSTOCKENTRY ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICE' AND KSQL_COL_NAME IN ('FINPUTAMOUNT')) 
 ALTER TABLE T_PUR_INVOICE ADD (FINPUTAMOUNT CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RECEIPT' AND KSQL_COL_NAME IN ('FINPUTAMOUNT')) 
 ALTER TABLE T_PUR_RECEIPT ADD (FINPUTAMOUNT CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_INVOICENTRY2 ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2' AND KSQL_COL_NAME IN ('FACTCHECKAMOUNT')) 
 ALTER TABLE T_PUR_INVOICENTRY2 ADD (FACTCHECKAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2' AND KSQL_COL_NAME IN ('FACTCHECKPRICE')) 
 ALTER TABLE T_PUR_INVOICENTRY2 ADD (FACTCHECKPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECK' AND KSQL_COL_NAME IN ('FINPUTAMOUNT')) 
 ALTER TABLE T_PUR_CHECK ADD (FINPUTAMOUNT CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECKENTRY2' AND KSQL_COL_NAME IN ('FDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_CHECKENTRY2 ADD (FDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECKENTRY2' AND KSQL_COL_NAME IN ('FACTCHECKAMOUNT')) 
 ALTER TABLE T_PUR_CHECKENTRY2 ADD (FACTCHECKAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECKENTRY2' AND KSQL_COL_NAME IN ('FACTCHECKPRICE')) 
 ALTER TABLE T_PUR_CHECKENTRY2 ADD (FACTCHECKPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDERENTRY_A' AND KSQL_COL_NAME IN ('FISCONTROLAMOUNTUP')) 
 ALTER TABLE T_PUR_ORDERENTRY_A ADD (FISCONTROLAMOUNTUP CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDERENTRY_A' AND KSQL_COL_NAME IN ('FAMOUNTUP')) 
 ALTER TABLE T_PUR_ORDERENTRY_A ADD (FAMOUNTUP DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDERENTRY_A' AND KSQL_COL_NAME IN ('FRELATEAPACCEPTTAXAMOUNT')) 
 ALTER TABLE T_PUR_ORDERENTRY_A ADD (FRELATEAPACCEPTTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDERENTRY_A' AND KSQL_COL_NAME IN ('FSUMAPACCEPTTAXAMOUNT')) 
 ALTER TABLE T_PUR_ORDERENTRY_A ADD (FSUMAPACCEPTTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ORDERENTRY_A' AND KSQL_COL_NAME IN ('FSUMACCEPTTAXAMOUNT')) 
 ALTER TABLE T_PUR_ORDERENTRY_A ADD (FSUMACCEPTTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SALOUTSTOCKENTRY_A' AND KSQL_COL_NAME IN ('FSUMACCEPTTAXAMOUNT')) 
 ALTER TABLE T_PUR_SALOUTSTOCKENTRY_A ADD (FSUMACCEPTTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SALOUTSTOCK_A' AND KSQL_COL_NAME IN ('FREJECTRESON')) 
 ALTER TABLE T_PUR_SALOUTSTOCK_A ADD (FREJECTRESON NVARCHAR(512) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SALOUTSTOCK_A' AND KSQL_COL_NAME IN ('FREJECTERID')) 
 ALTER TABLE T_PUR_SALOUTSTOCK_A ADD (FREJECTERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SALOUTSTOCK_A' AND KSQL_COL_NAME IN ('FREJECTDATE')) 
 ALTER TABLE T_PUR_SALOUTSTOCK_A ADD (FREJECTDATE DATETIME );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECKENTRY2_A' AND KSQL_COL_NAME IN ('FSUMINVAMOUNT')) 
 ALTER TABLE T_PUR_CHECKENTRY2_A ADD (FSUMINVAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECKENTRY2' AND KSQL_COL_NAME IN ('FUNMATCHAMOUNT')) 
 ALTER TABLE T_PUR_CHECKENTRY2 ADD (FUNMATCHAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_SALREJECTREASONATT') 
 CREATE TABLE T_PUR_SALREJECTREASONATT (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
 
/**End C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
