/**Begin D:\PDM_UPGRADE\PDM1\FCS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_CHECKCTRL_AMTCTRL' AND KSQL_COL_NAME IN ('FTARGETCONDITIONDESC'))
 ALTER TABLE T_FCS_CHECKCTRL_AMTCTRL ADD (FTARGETCONDITIONDESC NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_CHECKCTRL_AMTCTRL' AND KSQL_COL_NAME IN ('FTARGETCONDITION'))
 ALTER TABLE T_FCS_CHECKCTRL_AMTCTRL ADD (FTARGETCONDITION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_CHECKCTRL_AMTCTRL' AND KSQL_COL_NAME IN ('FTARGETCONDITION_TAG'))
 ALTER TABLE T_FCS_CHECKCTRL_AMTCTRL ADD (FTARGETCONDITION_TAG NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_CHECKCTRL_SUBAMT' AND KSQL_COL_NAME IN ('FOTHERCONDITIONDESC'))
 ALTER TABLE T_FCS_CHECKCTRL_SUBAMT ADD (FOTHERCONDITIONDESC NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_CHECKCTRL_SUBAMT' AND KSQL_COL_NAME IN ('FOTHERCONDITION'))
 ALTER TABLE T_FCS_CHECKCTRL_SUBAMT ADD (FOTHERCONDITION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_CHECKCTRL_SUBAMT' AND KSQL_COL_NAME IN ('FOTHERCONDITION_TAG'))
 ALTER TABLE T_FCS_CHECKCTRL_SUBAMT ADD (FOTHERCONDITION_TAG NCLOB );


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_PAYACCESS_RECORD_H')
 CREATE TABLE T_FCS_PAYACCESS_RECORD_H (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FENABLERID BIGINT DEFAULT 0 NOT NULL,
FENABLEDATE DATETIME,
FDISABLEDATE DATETIME,
FSRCENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FDESTENTITY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESTBILLID BIGINT DEFAULT 0 NOT NULL,
FSRCIDPROP NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDESTIDPROP NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISREPEATRESULT CHAR(1) DEFAULT '0' NOT NULL,
FISEXCESSRESULT CHAR(1) DEFAULT '0' NOT NULL,
FSRCENTRYPROP NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLPKID BIGINT DEFAULT 0 NOT NULL,
FDESTENTRYPROP NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESTBILLPKID BIGINT DEFAULT 0 NOT NULL,
FNEWWAY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FFULLLINKID NVARCHAR(2000) DEFAULT ' ' NOT NULL,
FBATCHNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FERRORMESSAGE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUCCESS CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_ARCHIVERECORD')
 CREATE TABLE T_FCS_ARCHIVERECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(60) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FFINISHTIME DATETIME,
FARCHIVESTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FHEARTBEATTIME DATETIME,
FTOTALCNT BIGINT DEFAULT 0 NOT NULL,
FFINISHCNT BIGINT DEFAULT 0 NOT NULL,
FPERCENT DECIMAL(10,2) DEFAULT 0 NOT NULL,
FARCHIVESETTINGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_ARCHIVESETTING')
 CREATE TABLE T_FCS_ARCHIVESETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(60) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FSRCTYPEID NVARCHAR(60) DEFAULT ' ' NOT NULL,
FARCHIVETYPEID NVARCHAR(60) DEFAULT ' ' NOT NULL,
FDAY INT DEFAULT 0 NOT NULL,
FLIVETIME INT DEFAULT 0 NOT NULL,
FARCHIVEFILTER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FARCHIVEFILTER_TAG NCLOB,
FTIMEPROP NVARCHAR(60) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_ARCHIVESETTING_L')
 CREATE TABLE T_FCS_ARCHIVESETTING_L (
FPKID NVARCHAR(60) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(20) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(60) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_PAYTRACELOG_H')
 CREATE TABLE T_FCS_PAYTRACELOG_H (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FSOURCE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYSTEP NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCLASSNAME NVARCHAR(200) DEFAULT ' ' NOT NULL,
FMETHODNAME NVARCHAR(200) DEFAULT ' ' NOT NULL,
FTAGINFO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDETAILINFO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDETAILINFO_TAG NCLOB DEFAULT ' ',
FLINENUM INT DEFAULT 0 NOT NULL,
FBILLTYPE NVARCHAR(60) DEFAULT ' ' NOT NULL,
FEXCEPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FEXCEPTION_TAG NCLOB DEFAULT ' ',
FLEVEL NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTRACEID NVARCHAR(60) DEFAULT ' ' NOT NULL,
FBILLNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_REPEATCTRLLOG_H')
 CREATE TABLE T_FCS_REPEATCTRLLOG_H (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FCOSTTIME INT DEFAULT 0 NOT NULL,
FSOURCEBILLTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FEXCEPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FEXCEPTION_TAG NCLOB DEFAULT ' ',
FTRACEID NVARCHAR(60) DEFAULT ' ' NOT NULL,
FREPEATSETID BIGINT DEFAULT 0 NOT NULL,
FLOGTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDESTBILLID BIGINT DEFAULT 0 NOT NULL,
FDESTBILLTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_PAYACCESS_SET' AND KSQL_COL_NAME IN ('FAPIPASS'))
 ALTER TABLE T_FCS_PAYACCESS_SET ADD (FAPIPASS CHAR(1) DEFAULT '0' NOT NULL );


 IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_PAYACCESS_RECORD_H_L')
  CREATE TABLE T_FCS_PAYACCESS_RECORD_H_L (
 FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
 FID BIGINT DEFAULT 0 NOT NULL,
 FLOCALEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
 FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
 FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL
 );

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_CHECKCTRL_AMTCTRL' AND KSQL_COL_NAME IN ('FSRCCONDITIONDESC'))
  ALTER TABLE T_FCS_CHECKCTRL_AMTCTRL ADD (FSRCCONDITIONDESC NVARCHAR(50) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_CHECKCTRL_AMTCTRL' AND KSQL_COL_NAME IN ('FSRCCONDITION'))
  ALTER TABLE T_FCS_CHECKCTRL_AMTCTRL ADD (FSRCCONDITION NVARCHAR(255) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_CHECKCTRL_AMTCTRL' AND KSQL_COL_NAME IN ('FSRCCONDITION_TAG'))
  ALTER TABLE T_FCS_CHECKCTRL_AMTCTRL ADD (FSRCCONDITION_TAG NCLOB );

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