IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_GL_INTELLEXECPARAM') 
 CREATE TABLE T_GL_INTELLEXECPARAM (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBIZAPP BIGINT DEFAULT 0 NOT NULL,
FBUSSINESS NVARCHAR(80) DEFAULT ' ' NOT NULL,
FOPER NVARCHAR(80) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_GL_INTELLEXECPARAM_L') 
 CREATE TABLE T_GL_INTELLEXECPARAM_L (
FPKID NVARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FDESC NVARCHAR(400) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_GL_INTELLEXECPARAMENTRY_L') 
 CREATE TABLE T_GL_INTELLEXECPARAMENTRY_L (
FPKID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FPARAMDESC NVARCHAR(400) DEFAULT ' ' NOT NULL,
FPARAMNAME NVARCHAR(200) DEFAULT ' ' NOT NULL,
FCOMBOVAL NVARCHAR(1000) DEFAULT ' '
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_GL_INTELLEXECPARAMENTRY') 
 CREATE TABLE T_GL_INTELLEXECPARAMENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPARAM NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPARAMTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FPARAMVAL NVARCHAR(100) DEFAULT ' ',
FREQUIRE CHAR(1) DEFAULT '0'
);

 EXEC p_AlterColumn 'T_GL_INTELLEXECPARAMENTRY_L', 'FPKID', 'NVARCHAR(18)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_GL_INTELLEXECPARAMENTRY', 'FREQUIRE', 'CHAR(1)', 'NOT NULL', '0010', '''0''';

 EXEC p_AlterColumn 'T_GL_INTELLEXECPARAM', 'FBIZAPP', 'NVARCHAR(18)', 'NOT NULL', '1111', ''' ''';
 
 
 -- 银行账户调度升级

UPDATE t_gl_intellexecoperentry SET FOPER = 'downcurrentdetail' WHERE FBUSSINESS = 'cas_schedulebyacctbank' AND FOPER = 'downdetail';
UPDATE t_gl_intellexecoperentry SET FOPER = 'downcurrentbalance' WHERE FBUSSINESS = 'cas_schedulebyacctbank' AND FOPER = 'downbalance';

UPDATE t_gl_intellexecoperentry SET FBUSSINESS = 'am_acctbank_schedule' , FAPPID = '/LSWD74E9D/Q' WHERE FBUSSINESS = 'cas_schedulebyacctbank';



DELETE FROM t_gl_intellexecparam WHERE FID = 691706346944514048;
INSERT INTO t_gl_intellexecparam(FID,FBUSSINESS,FNUMBER,FBIZAPP,FOPER) VALUES (691706346944514048,'am_acctbank_schedule','tmc_balance_schedule','/LSWD74E9D/Q','downhistorybalance'); 
DELETE FROM t_gl_intellexecparam WHERE FID = 692643648420078592;
INSERT INTO t_gl_intellexecparam(FID,FBIZAPP,FBUSSINESS,FOPER,FNUMBER) VALUES (692643648420078592,'/LSWD74E9D/Q','am_acctbank_schedule','downhistorydetail','tmc_transdetail_schedule'); 



DELETE FROM t_gl_intellexecparamentry WHERE FENTRYID = 691706346944350208;
INSERT INTO t_gl_intellexecparamentry(FID,FREQUIRE,FPARAM,FPARAMVAL,FENTRYID,FPARAMTYPE,FSEQ) VALUES (691706346944514048,'0','schedule_cycle','2',691706346944350208,'int',1); 
DELETE FROM t_gl_intellexecparamentry WHERE FENTRYID = 692643648420078593;
INSERT INTO t_gl_intellexecparamentry(FID,FREQUIRE,FPARAM,FPARAMVAL,FENTRYID,FPARAMTYPE,FSEQ) VALUES (692643648420078592,'0','schedule_cycle','2',692643648420078593,'int',1); 


DELETE FROM t_gl_intellexecparam_l WHERE FPKID = '051BZ+Y1MLOH';
INSERT INTO t_gl_intellexecparam_l(FDESC,FPKID,FNAME,FLOCALEID,FID) VALUES ('资金交易余额下载周期','051BZ+Y1MLOH','资金交易余额下载周期','zh_CN',691706346944514048); 
DELETE FROM t_gl_intellexecparam_l WHERE FPKID = '051BZ+Y1MLOI';
INSERT INTO t_gl_intellexecparam_l(FDESC,FPKID,FNAME,FLOCALEID,FID) VALUES ('資金交易餘額下載周期','051BZ+Y1MLOI','資金交易餘額下載周期','zh_TW',691706346944514048); 
DELETE FROM t_gl_intellexecparam_l WHERE FPKID = '051CGDM3/9C1';
INSERT INTO t_gl_intellexecparam_l(FDESC,FPKID,FNAME,FLOCALEID,FID) VALUES ('资金交易明细下载周期','051CGDM3/9C1','资金交易明细下载周期','zh_CN',692643648420078592); 
DELETE FROM t_gl_intellexecparam_l WHERE FPKID = '051CGDM3/9C2';
INSERT INTO t_gl_intellexecparam_l(FDESC,FPKID,FNAME,FLOCALEID,FID) VALUES ('資金交易明細下載周期','051CGDM3/9C2','資金交易明細下載周期','zh_TW',692643648420078592); 


DELETE FROM t_gl_intellexecparamentry_l WHERE FPKID = '04YWB=Q95QNS';
INSERT INTO t_gl_intellexecparamentry_l(FCOMBOVAL,FPKID,FPARAMNAME,FENTRYID,FPARAMDESC,FLOCALEID) VALUES (' ','04YWB=Q95QNS','调度周期',691706346944350208,'查询时间周期，指查询几天范围内的交易余额','zh_CN'); 
DELETE FROM t_gl_intellexecparamentry_l WHERE FPKID = '04YWB=Q95QNT';
INSERT INTO t_gl_intellexecparamentry_l(FCOMBOVAL,FPKID,FPARAMNAME,FENTRYID,FPARAMDESC,FLOCALEID) VALUES (' ','04YWB=Q95QNT','調度周期',691706346944350208,'查詢時間周期，指查詢幾天範圍內的交易餘額','zh_TW'); 
DELETE FROM t_gl_intellexecparamentry_l WHERE FPKID = '051CGDM3/9C3';
INSERT INTO t_gl_intellexecparamentry_l(FCOMBOVAL,FPKID,FPARAMNAME,FENTRYID,FPARAMDESC,FLOCALEID) VALUES (' ','051CGDM3/9C3','调度周期',692643648420078593,'查询时间周期，指查询几天范围内的交易明细','zh_CN'); 
DELETE FROM t_gl_intellexecparamentry_l WHERE FPKID = '051CGDM3/9C4';
INSERT INTO t_gl_intellexecparamentry_l(FCOMBOVAL,FPKID,FPARAMNAME,FENTRYID,FPARAMDESC,FLOCALEID) VALUES (' ','051CGDM3/9C4','調度周期',692643648420078593,'查詢時間周期，指查詢幾天範圍內的交易明細','zh_TW'); 
