【问题标题】:Skip to next record in a pl sql Cursor with Bulk Collect使用 Bulk Collect 跳到 pl sql 游标中的下一条记录
【发布时间】:2014-06-05 12:42:07
【问题描述】:

请分析下面的代码 sn-p 并提出一种跳到光标中下一条记录的方法。

开始

OPEN cs_migrate_drop_ntd_object_status;

LOOP

    FETCH cs_migrate_drop_ntd_object_status BULK COLLECT INTO r_current_loc_equip LIMIT 200;

    FOR i IN 1..r_current_loc_equip.COUNT
    LOOP
        IF ( r_current_loc_equip(i).status = 'YES' ) THEN
            **-- Here I want to skip to next record fetched by the bulk collect cursor**
        ELSE
            Do something else;

【问题讨论】:

    标签: plsql cursor bulk-collect


    【解决方案1】:

    使用CONTINUE:

    FOR i IN 1..r_current_loc_equip.COUNT
    LOOP
        IF ( r_current_loc_equip(i).status = 'YES' ) THEN
            CONTINUE;
        ELSE...
    

    你也可以这样使用:

    FOR i IN 1..r_current_loc_equip.COUNT
    LOOP
        CONTINUE WHEN r_current_loc_equip(i).status = 'YES';
        Do something else;
    

    (更好的是,如果您不想处理 status='YES' 的行,请不要首先在光标中选择它们。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-31
      • 1970-01-01
      • 2020-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多