游标的属性


(1) %ISOPEN  打开属性 布尔型 打开为TRUE       
        判断'光标'是否打开如未打开则打开'光标'
        IF NOT(CORSOR_NAME%ISOPEN) THEN
           OPEN CORSOR_NAME;
        END IF;
       FETCH CORSOR_NAME INTO ...
   (2) %NOTFOUND 布尔型 最近一次'FETCH'返回无结果 则为TRUE
          OPEN CORSOR_NAME;
          LOOP
               FETCH CORSOR_NAME INTO ...   
               EXIT WHEN CORSOR_NAEM%NOTFOUND;
          END LOOP;
   (3) %FOUND 布尔型 最近一次'FETCH'返回无结果 则为FALSE
         OPEN CORSOR_NAME;
          
         WHILE CORSOR_NAME%FOUND LOOP
               ......
               FETCH CORSOR_NAME INTO ... 
         END LOOP;
         CLOSE CORSOR_NAME; 
   (4) %ROWCOUNT NUMVER型 为游标取出的行数
         OPEN CORSOR_NAME;
         LOOP
            FETCH CORSOR_NAME INTO ... 
            EXIT WHEN CORSOR_NAME%ROWCOUNT>5; 
             ......    
         END LOOP;         
         CLOSE CORSOR_NAME; 

你可能感兴趣的:(plsql,游标,属性)