我是刚学pl/sql,遇到一个问题,首先我定义了三个变量,
--这个是游标读取oracle数据库里边的数据;
cursor emp_cursor is
select empno, ename, sal from scott.emp;
--这里我将table的每一行类型定义为与游标的rowtype;
type emp_table is table of
emp_cursor % rowtype
index by BINARY_INTEGER;
--定义当前table的位置;
current_count INTEGER := 1;
然后我在接下来的模块读取emp_cursor:
FOR t_emp in emp_cursor loop
dbms_output.put_line('Loop :' || current_count);
--接下来这句语句却通过不了,不知应该怎么写才行呢?
emp_table(current_count).empno := t_emp.empno;
current_count := current_count + 1;
end loop;
这里的emp_table(current_count).empno := t_emp.empno为什么会出错?谁能告诉我?应该怎么写?
不好意思,原来我搞错了,type了一个类型应该多加个变量引用这个类型,然后使用这个变量就可以了。我直接使用这个类型才会出错。有谁要答的答了直接给分。