
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INSTOCKENTRY_A' AND KSQL_COL_NAME IN ('FUNMATCHBASEQTY')) 
 ALTER TABLE T_PUR_INSTOCKENTRY_A ADD (FUNMATCHBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INSTOCKENTRY_A' AND KSQL_COL_NAME IN ('FISCHECKORINVOICE')) 
 ALTER TABLE T_PUR_INSTOCKENTRY_A ADD (FISCHECKORINVOICE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RECEIPTENTRY_A' AND KSQL_COL_NAME IN ('FISCHECKORINVOICE')) 
 ALTER TABLE T_PUR_RECEIPTENTRY_A ADD (FISCHECKORINVOICE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RECEIPTENTRY_A' AND KSQL_COL_NAME IN ('FUNMATCHBASEQTY')) 
 ALTER TABLE T_PUR_RECEIPTENTRY_A ADD (FUNMATCHBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RECEIPTENTRY_A' AND KSQL_COL_NAME IN ('FUNMATCHQTY')) 
 ALTER TABLE T_PUR_RECEIPTENTRY_A ADD (FUNMATCHQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_PUR_RETURNENTRY_A', 'FUNMATCHQTY', 'DECIMAL(23,10)', 'NOT NULL', '0100', '0';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RETURNENTRY_A' AND KSQL_COL_NAME IN ('FISCHECKORINVOICE')) 
 ALTER TABLE T_PUR_RETURNENTRY_A ADD (FISCHECKORINVOICE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RETURNENTRY_A' AND KSQL_COL_NAME IN ('FUNMATCHBASEQTY')) 
 ALTER TABLE T_PUR_RETURNENTRY_A ADD (FUNMATCHBASEQTY 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 ('FUNMATCHQTY')) 
 ALTER TABLE T_PUR_CHECKENTRY2 ADD (FUNMATCHQTY 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 ('FUNMATCHAMT')) 
 ALTER TABLE T_PUR_CHECKENTRY2 ADD (FUNMATCHAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_UPDATEPARAMCONFIG') 
 CREATE TABLE T_PUR_UPDATEPARAMCONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FPARAMNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPARAMKEY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPARAMVALUE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPARAMMSG NVARCHAR(255) DEFAULT ' ' NOT NULL
);

 EXEC P_ALTERPK 'PK_T_PUR_UPDATEPARAMCONFIG', 'T_PUR_UPDATEPARAMCONFIG', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'T_PUR_CONFIG_FPARAMKEY') CREATE INDEX T_PUR_CONFIG_FPARAMKEY ON T_PUR_UPDATEPARAMCONFIG ( FPARAMKEY );

