`

Oracle标签的使用

阅读更多
在用Code Xpert扫描代码时,提示“Avoid unlabeled nested LOOPs”.
即避免使用没有标签的嵌套循环。
那么标签是怎么使用的呢?
看下面的例子:

procedure test_label is
            cursor mycursor is
                  select t.trustee from xxxt where rownum <= 10;
            v_list mycursor%rowtype;
      begin
            open mycursor;
            <<a>>
            loop
                  fetch mycursor
                        into v_list;
                  exit when mycursor%notfound;
                  dbms_output.put_line(v_list.trustee);
            end loop a;
            close mycursor;
      
            <<la>>
            for i in 1 .. 9
            loop
                  <<lb>>
                  for j in 1 .. i
                  loop
                        dbms_output.put(i || '*' || j || '=' || i * j ||
                                        '    ');
                  end loop lb;
                  dbms_output.new_line();
            end loop la;
      exception
            when others then
                  dbms_output.put_line('errorCode:' || sqlcode ||
                                       ',errorInfo:' || sqlerrm);
      end test_label;



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics