Loop Exit Time

Source: Internet
Author: User
Tags manual writing
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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.