为什么只更新一条记录?
我是一位超级菜鸟,还请各位大哥帮忙!
就是下面的代码:
int li_row,i,li_year,ldec_voucher_id,ldec_voucher_item_id
string ls_print_flag,ls_temp_date
date ld_current_date,ld_date
datetime ldt_current_date
li_row=dw_select_printed.rowcount()
select system_date into :ldt_current_date from routinestatus;
ld_current_date=date(ldt_current_date)
for i = 1 to li_row
ls_print_flag=dw_select_printed.getitemstring(i,"print_flag")
if ls_print_flag="1" then
ldec_voucher_id=dw_select_printed.getitemdecimal(i,"voucher_id")
ldec_voucher_item_id=dw_select_printed.getitemdecimal(i,"voucher_item_id")
ld_date=date(dw_select_printed.getitemdatetime(i,"date"))
EXECUTE IMMEDIATE "BEGIN TRANSACTION" USING SQLCA;
IF SQLCA.SQLCode<0 THEN
MessageBox("错误","数据库事务启动错误!")
END IF
if ld_date>date(string(year(ld_current_date))+"-07-01") then
update persondetailaccount
set print_flag="1"
where account=:gs_unitaccount and
person_account=:gs_personaccount and
voucher_id=:ldec_voucher_id and
voucher_item_id=:ldec_voucher_item_id;
end if
if ld_date<date(string(year(ld_current_date))+"-07-01") then
update historyhouse..prioryear_persondetailaccount
set print_flag="1"
where account=:gs_unitaccount and
person_account=:gs_personaccount and
voucher_id=:ldec_voucher_id and
voucher_item_id=:ldec_voucher_item_id;
end if
IF SQLCA.SQLCode<0 THEN
EXECUTE IMMEDIATE "ROLLBACK TRANSACTION" USING SQLCA;
MessageBox("错误","数据库数据修改错误!")
END IF
EXECUTE IMMEDIATE "COMMIT TRANSACTION" USING SQLCA;
end if
NEXT
close(parent)