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.
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;
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;