游标循环更新表由许多值组成

时间:2018-06-07 08:16:45

标签: oracle plsql sql-update database-cursor

ET_BP_FACT

我想通过许多值示例(25,50,75)更新表Intent intent = new Intent(Intent.ACTION_VIEW) Uri outputFileUri = FileProvider.getUriForFile(getActivity(), BuildConfig.APPLICATION_ID + ".provider", file); intent.setDataAndType(outputFileUri, "application/pdf"); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent in = Intent.createChooser(intent, "Open File"); startActivity(in); 从Cursor返回但是当我执行由(25,25,25)更新的表时

我认为循环中存在问题

1 个答案:

答案 0 :(得分:0)

那是因为UPDATE的{​​{1}}子句没有“引用”游标的值。像这样:

WHERE

我建议你总是在列名前面加上表别名,因为 - 查看你的代码,没有办法猜测哪个表DECLARE CURSOR contacts IS SELECT month_id, org_unit_id, --> include additional columns here ... SUM (budget) AS budget FROM et_bp_gl_account a, et_bp_fact f WHERE f.gl_account_id = a.gl_account_id AND total_flag = 0 GROUP BY month_id, org_unit_id; BEGIN FOR r IN contacts LOOP UPDATE et_bp_fact SET budget = r.budget WHERE gl_account_id IN (SELECT total_element FROM et_bp_gl_account g, et_bp_fact f WHERE f.gl_account_id = g.gl_account_id -- AND f.org_unit_id = r.org_unit_id --> ... and reference them here ... AND g.month_id = r.month_id); --> ... or, possibly, here END LOOP; END; 和{{1属于,所以我的代码可能(或可能不)工作,但我希望你有一般的想法。