哪位高数帮我看一下这简单的游标问题?头疼啊,在线等!

llkk1979 2004-12-02 02:58:58
a = daysafter(ls_indate1,ls_indate2) //返回两个日期段的天数
b = 0 //初始值为0
////删除原表数据
delete from c_daytemp using sqlca ;
commit;
//////
DO WHILE b<=a
////用游标往表导入数据
ls_enddate = relativedate(ls_indate1,b) //循环结束日期
tablename = "tt" + right(string(ls_enddate, "yyyymmdd"),6) //循环结束时的表名
DECLARE C1 CURSOR FOR
SELECT ssn,term_ssn,tx_acc,right(mer_code,15),mer_name,round(mer_comm,5),term,act_date,act_time,post_date,tran_code,tran_curr,sett_curr,round(tran_amt,2),round(setm_amt,2),round(n_tran_amt,2),round(n_setm_amt,2),auth_code,cov_rate,cb_bank,round(hs_amt,2), round(hs_comm,2), round(c_s_amt,2),round(c_t_amt,2),round(nc_s_amt,2),round(nc_t_amt,2),round(comm_s_amt,2),round(comm_t_amt,2),card_no,ob_bank
FROM :tablename
USING mytrans_dbf;
OPEN C1;
FETCH C1 INTO :ls_ssn,:ls_term_ssn,:ls_tx_acc,:ls_mer_code,:ls_mer_name,:ls_mer_comm,:ls_term,:ls_act_date,:ls_act_time,:ls_post_date,:ls_tran_code,:ls_tran_curr,:ls_sett_curr,:ls_tran_amt,:ls_setm_amt,:ls_n_tran_amt,:ls_n_setm_amt,:ls_auth_code,:ls_cov_rate,:ls_cb_bank,:ls_hs_amt,:ls_hs_comm,:ls_c_s_amt,:ls_c_t_amt,:ls_nc_s_amt,:ls_nc_t_amt,:ls_comm_s_amt,:ls_comm_t_amt,:ls_card_no,:ls_ob_bank;
DO WHILE mytrans_dbf.sqlcode = 0
INSERT INTO c_daytemp( ssn, term_ssn, tx_acc, mer_code, mer_name, mer_comm, term, act_date, act_time, post_date, tran_code, tran_curr, sett_curr, tran_amt, setm_amt, n_tran_amt, n_setm_amt, auth_code, cov_rate, cb_bank, hs_amt, hs_comm, c_s_amt, c_t_amt, nc_s_amt, nc_t_amt, comm_s_amt, comm_t_amt, card_no, ob_bank,tag_no,sum_amt,adjust_amt,noadjust_amt)
VALUES (:ls_ssn,:ls_term_ssn,:ls_tx_acc,:ls_mer_code,:ls_mer_name,:ls_mer_comm,:ls_term,:ls_act_date,:ls_act_time,:ls_post_date,:ls_tran_code,:ls_tran_curr,:ls_sett_curr,:ls_tran_amt,:ls_setm_amt,:ls_n_tran_amt,:ls_n_setm_amt,:ls_auth_code,:ls_cov_rate,:ls_cb_bank,:ls_hs_amt,:ls_hs_comm,:ls_c_s_amt,:ls_c_t_amt,:ls_nc_s_amt,:ls_nc_t_amt,:ls_comm_s_amt,:ls_comm_t_amt,:ls_card_no,:ls_ob_bank,:ls_tag,:ls_tran_amt,:ls_adjust_amt,:ls_noadjust_amt) USING sqlca ;
FETCH C1 INTO :ls_ssn,:ls_term_ssn,:ls_tx_acc,:ls_mer_code,:ls_mer_name,:ls_mer_comm,:ls_term,:ls_act_date,:ls_act_time,:ls_post_date,:ls_tran_code,:ls_tran_curr,:ls_sett_curr,:ls_tran_amt,:ls_setm_amt,:ls_n_tran_amt,:ls_n_setm_amt,:ls_auth_code,:ls_cov_rate,:ls_cb_bank,:ls_hs_amt,:ls_hs_comm,:ls_c_s_amt,:ls_c_t_amt,:ls_nc_s_amt,:ls_nc_t_amt,:ls_comm_s_amt,:ls_comm_t_amt,:ls_card_no,:ls_ob_bank;
st_register.show()
LOOP
CLOSE C1;
b=b+1
LOOP

疑问:以上代码在一个按钮里。第一次导的数据是290行,这是正确的;但在再点击这个按钮时,数据变成580行了,再点就870了...太奇怪了,难道游标没释放?请高手指教
...全文
86 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
coopie 2004-12-07
你把数据库连接也dis了看看行不行?
回复
llkk1979 2004-12-02
奇怪了,我加了COMMIT还是不行啊,数据逐倍往上增
回复
workhand 2004-12-02
CLOSE C1;
commit;试试
回复
相关推荐
发帖
数据库相关
创建于2007-09-28

734

社区成员

PowerBuilder 数据库相关
申请成为版主
帖子事件
创建了帖子
2004-12-02 02:58
社区公告
暂无公告