は同じものです。直接値 '020'を使用したときの出力は377でした。変数を使用したときの出力は16でした。なぜ違うのか分からないのですか?実際に私はカウントが(1)16 知っている、私はにselect文の条件を変更し変数を使用しているselectステートメントを使用しているpl/sql forループは間違った結果を出しますか?
city_no:='020';
need_kinds := 0;
for need_item in (select n.rootcode, n.need2018, n.got2018
from jq_temp_hy_need_2018 n
where n.city_no = city_no
and (n.need2018 - n.got2018) > 0) loop
current_need_map(need_item.rootcode) := need_item.need2018 -
need_item.got2018;
already_get_map(need_item.rootcode) := need_item.got2018;
need_kinds:=need_kinds+1;
end loop;
-- out put 377
dbms_output.put_line(need_kinds);
がn.city_no =「020」は、出力値が16になった:以下のSQLコードですn.city_no = '020'。
city_no:='020';
need_kinds := 0;
for need_item in (select n.rootcode, n.need2018, n.got2018
from jq_temp_hy_need_2018 n
where n.city_no = '020'
and (n.need2018 - n.got2018) > 0) loop
current_need_map(need_item.rootcode) := need_item.need2018 -
need_item.got2018;
already_get_map(need_item.rootcode) := need_item.got2018;
need_kinds:=need_kinds+1;
end loop;
-- out put 16
dbms_output.put_line(need_kinds);
ありがとう、それは大きな間違いでした..... – Jaycee