oracle变量表类型declaretype my_emp is table of scott.emp%rowtypeindex by binary_integer;new_emp my_emp;v_num number:=0;cursor cur_emp is select empno,ename,job,sal from scott.emp;--1.cursor 是个什么东东?beginfor v_emp in cur_emp loop --2.v
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 15:50:32
oracle变量表类型declaretype my_emp is table of scott.emp%rowtypeindex by binary_integer;new_emp my_emp;v_num number:=0;cursor cur_emp is select empno,ename,job,sal from scott.emp;--1.cursor 是个什么东东?beginfor v_emp in cur_emp loop --2.v
oracle变量表类型
declare
type my_emp is table of scott.emp%rowtype
index by binary_integer;
new_emp my_emp;
v_num number:=0;
cursor cur_emp is select empno,ename,job,sal from scott.emp;--1.cursor 是个什么东东?
begin
for v_emp in cur_emp loop --2.v_emp是个什么东东?怎么和正常for语句不一样?
v_num:=v_num+1;
select * into new_emp(v_num) from scott.emp
where ename=v_emp.ename; ename --3.和v_ename是哪里来的?
end loop;
for i in 1..new_emp.count loop
dbms_output.put_line(new_emp(i).empno ||','||new_emp(i).ename||','||new_emp(i).job||
','||new_emp(i).sal);
end loop;
end;
oracle变量表类型declaretype my_emp is table of scott.emp%rowtypeindex by binary_integer;new_emp my_emp;v_num number:=0;cursor cur_emp is select empno,ename,job,sal from scott.emp;--1.cursor 是个什么东东?beginfor v_emp in cur_emp loop --2.v
1.cursor指的是游标,这里是定义一个游标,下面for循环中用
2.v_emp是个变量,通过游标cur_emp每次循环取值用的
3.v_emp.ename是游标中查询出来的,就是这句 select empno,ename,job,sal from scott.emp中查到的结果ename