%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;
http://leettest.com