TYPE MYCURA IS REF CURSOR RETURN EMP%ROWTYPE;求解这句话是什么 意思

解决方案 »

  1.   

    声明一个动态游标类型 mycura ,结果集的结构与emp表相同.这只是一个类型需要生命一个变量后才可以使用.CURR MYCURA ;
      

  2.   

    我想问下那 个%号和后面的ROWtype是什么作用 还有前面你的emp
      

  3.   

    emp.empno%type 这个表示emp表中empno列的字段类型emp%rowtype 表示emp表的record类型的变量,有点解释不清楚.附上一段官方说明The %ROWTYPE attribute lets you declare a record variable that represents either a full or partial row of a database table or view.For every column of the full or partial row, the record has a field with the same name and data type. If the structure of the row changes, then the structure of the record changes accordingly.
      

  4.   

    DECLARE 
    TYPE mycura IS REF CURSOR RETURN emp%ROWTYPE; --声明强ref类型mycura,其结构为EMP表
    vrefcura mycura; --声明mycura类型的变量
    vreccura  vrefcura%ROWTYPE; --声明mycura类型变量的结果集
    BEGIN 
      OPEN vrefcura FOR select * from emp;--获得游标
      LOOP
        FETCH vrefcura INTO vreccura;
        EXIT WHEN vrefcura%NOTFOUND;
        Dbms_Output.put_line('the EMP_NAME is :'||vreccura.EMPNM);
      END LOOP;
      CLOSE vrefcura;
    END;