Open parameters; -- get the View list loop fetch cur_view_name_detail into lv_table_name; lv_detail_ SQL: = Replace (parameters, 'vw _ detail', lv_table_name); lv_detail_ SQL: = Replace (lv_detail_ SQL, 'g _ run_day_n ', to_char (g_run_day_n); open cur_detail for lv_detail_ SQL; -- using (g_run_day_n );
......
Commit; exit when cur_detail % notfound or cur_detail % notfound is null; end loop; close cur_detail; province (1, g_package_proce_name, 4, 'end -- Compare Province: '| lv_table_name ); exit when detail % notfound or cur_view_name_detail % notfound is null; end loop; close cur_view_name_detail; terminate (1, g_package_proce_name, 5, 'end -- Compare behavior 31 provinces '); Commit;
This is a two-cycle cursor extraction and a dynamic statement.
The External Loop mainly obtains the physical table name, and replaces the table name and time parameter of the dynamic statement by the replacement method to form a real SQL statement.
The second cycle is to execute dynamic statements and extract data to the temporary table.
BackCodeIs the exit condition.
If the External Loop has only one record, the internal loop will be executed twice.
Later, my colleague reminded me that this is a loop of do... while first executed and then judged.
For l_cur_deal_table in (select table_type, rule_no, sub_rule_no as provcodde, table_name from source_table_dic_t where rule_no = pi_rule_no)
Loop
...
End loop;
The condition is determined first and then executed without manual writing.
Therefore, add a judgment statement before execution.
Open parameters; -- get the View list loop fetch cur_view_name_detail into lv_table_name; lv_detail_ SQL: = Replace (parameters, 'vw _ detail', lv_table_name); lv_detail_ SQL: = Replace (lv_detail_ SQL, 'g _ run_day_n ', to_char (g_run_day_n ));
Exit when cur_view_name_detail % notfound or cur_view_name_detail % notfound is null;