/**Begin D:\PDM_UPGRADE\PDM1\CAS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_SMARTMATCH_E' AND KSQL_COL_NAME IN ('FDCONDITION')) 
 ALTER TABLE T_CAS_SMARTMATCH_E ADD (FDCONDITION NVARCHAR(1024) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_SMARTMATCH_E' AND KSQL_COL_NAME IN ('FDCONDITIONREAL')) 
 ALTER TABLE T_CAS_SMARTMATCH_E ADD (FDCONDITIONREAL NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_SMARTMATCH_E' AND KSQL_COL_NAME IN ('FDCONDITIONREAL_TAG')) 
 ALTER TABLE T_CAS_SMARTMATCH_E ADD (FDCONDITIONREAL_TAG NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_SMARTMATCH_E' AND KSQL_COL_NAME IN ('FBIZCONDITION')) 
 ALTER TABLE T_CAS_SMARTMATCH_E ADD (FBIZCONDITION NVARCHAR(1024) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_SMARTMATCH_E' AND KSQL_COL_NAME IN ('FBIZCONDITIONREAL')) 
 ALTER TABLE T_CAS_SMARTMATCH_E ADD (FBIZCONDITIONREAL NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_SMARTMATCH_E' AND KSQL_COL_NAME IN ('FBIZCONDITIONREAL_TAG')) 
 ALTER TABLE T_CAS_SMARTMATCH_E ADD (FBIZCONDITIONREAL_TAG NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_SMARTMATCH_E' AND KSQL_COL_NAME IN ('FMULTIPLE')) 
 ALTER TABLE T_CAS_SMARTMATCH_E ADD (FMULTIPLE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_SMARTMATCH_E' AND KSQL_COL_NAME IN ('FREMARKT')) 
 ALTER TABLE T_CAS_SMARTMATCH_E ADD (FREMARKT NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_SMARTMATCH_E' AND KSQL_COL_NAME IN ('FISENABLE')) 
 ALTER TABLE T_CAS_SMARTMATCH_E ADD (FISENABLE CHAR(1) DEFAULT '1' NOT NULL );
 
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AUTOMATCHRESULT' AND KSQL_COL_NAME ='FRULEENTRYID') 
 ALTER TABLE T_CAS_AUTOMATCHRESULT ADD (FRULEENTRYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AUTOMATCHRESULT' AND KSQL_COL_NAME ='RULENAME') 
 ALTER TABLE T_CAS_AUTOMATCHRESULT ADD (RULENAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_AUTOMATCHRESULT' AND KSQL_COL_NAME IN ('FRULENAME')) 
 ALTER TABLE T_CAS_AUTOMATCHRESULT ADD (FRULENAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
 
 EXEC p_AlterColumn 'T_CAS_AUTOCALRESULT_E', 'FACCTNAME', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_RECOPLOGBILL') 
CREATE TABLE T_CAS_RECOPLOGBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FRECBILLID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FDISCOUNTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFEE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOPTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FACTRECAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FBIZAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOREBILLTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYDETAILINFO_TAG NCLOB,
FENTRYDETAILINFO NCLOB,
FSETTLEORG BIGINT DEFAULT 0 NOT NULL,
FUNSETTLEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSETTLEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOREBILLSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOREBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUPDATETIME DATETIME,
FCONTRACT NVARCHAR(50) DEFAULT ' ' NOT NULL
);

/**End D:\PDM_UPGRADE\PDM1\CAS_table.sql **/
