%TYPE 用在变量的声明里,用于取得表中的字段类型;
%ROWTYPE 用于声明基于某个表的行类型;
示例:
%ROWTYPE 使用
DECLARE
CURSOR pdct_cur
IS SELECT * FROM PRODUCTINFO;
cur_prodcrd productinfo%ROWTYPE;
BEGIN
OPEN pdct_cur;
FETCH pdct_cur INTO cur_prodrcd;
DBMS_OUTPUT_PUTLINE(cur_prodrcd.productid '-' cur_prodrcd.productname);
CLOSE pdct_cur;
END;
%TYPE 使用
DECLARE
cur_productid varchar(10);
cur_prodctname productinfo.productname%TYPE;
CURSOR pdct_cur
IS SELECT productid,productname FROM PRODUCTINFO;
BEGIN
OPEN pdct_cur;
FETCH pdct_cur INTO cur_productid ,cur_productname;
DBMS_OUTPUT_PUTLINE(productid '-' productname);
CLOSE pdct_cur;
END;