來換種變量賦值了怎么就不行了呢?
set serveroutput on
declare
cursor hi is select ename,sal from emp;
--光標(biāo)就是集合來的? hi就是設(shè)置的數(shù)組變量
aa emp%rowtype;
begin
open hi;
loop
FETCH hi INTO aa ;
--取出 定義的變量放在集合里面?? fetch根據(jù)記錄變量一條條取出
EXIT when hi%notfound;
dbms_output.put_line(aa.ename||'的薪水是'|| aa.sal);
end loop;
close hi;
end;
/
2016-06-26
你這里:aa emp%rowtype ?使用的是記錄型變量,指的是一行的所有的列:empno,ename,empjob,mgr...等8列,但你的光標(biāo):cursor hi is select ename,sal from emp; 就取到兩列,你把兩列的值往八列里面插肯定不行的!好好復(fù)習(xí)下記錄型變量的使用
2016-04-24
你使用record類型來存儲(chǔ)游標(biāo)中的數(shù)據(jù)試試
typer record_emp is record
(
var_ename emp.ename%type,
var_sal emp.ename%type
);
aa record_emp