as
type r_cursor is ref cursor;
rt_cursor r_cursor;
cc table2%rowtype;
num number(3):=0;
num1 number(3):=0;
begin
open rt_cursor for select empno as num,sum(sal*12+nvl(comm,0)*12)as value1 from emp where empno in (select empno from emp) ;
num1:= rt_cursor%rowcount;
loop
fetch rt_cursor into cc;
exit when rt_cursor%notfound;
num:=num+1;
insert into table2(id,num)values(cc.num,cc.value1);
end loop;
close rt_cursor;
end charuhanshu;
输入程序后的errors
15/48 PLS-00302: 必须声明 'VALUE1' 组件
15/48 PL/SQL: ORA-00984: 列在此处不允许
15/4 PL/SQL: SQL Statement ignored
table2的结构
ID NUMBER(8) Y
SAL NUMBER(8) Y
怎么样解决PLS-00302: 必须声明 组件这个错误请大侠不吝赐教
4 个解决方案
#1
游标只保存列名
insert into table2(id,num)values( rt_cursor.num, rt_cursor.value1);
insert into table2(id,num)values( rt_cursor.num, rt_cursor.value1);
#2
这个方法不行还是报错
15/52 PLS-00487: 对变量 'RT_CURSOR' 的引用无效
15/62 PL/SQL: ORA-00984: 列在此处不允许
15/4 PL/SQL: SQL Statement ignored
15/52 PLS-00487: 对变量 'RT_CURSOR' 的引用无效
15/62 PL/SQL: ORA-00984: 列在此处不允许
15/4 PL/SQL: SQL Statement ignored
#3
type r_cursor is ref cursor;
rt_cursor r_cursor;
10G及以上把这两句删了。
改成 rt_cursor sys_refcursor;
rt_cursor r_cursor;
10G及以上把这两句删了。
改成 rt_cursor sys_refcursor;
#4
问题解决了
恩我是这样解决的
create or replace procedure charuhanshu
as
cursor rt_cursor is select num,value1 from( select empno as num,sum(sal*12+nvl(comm,0)*12)as value1 from emp where empno in (select empno from emp)group by empno) ;
cc rt_cursor%rowtype;
begin
for cc in rt_cursor loop
insert into table2(id,num)values(cc.num,cc.value1);
end loop;
end charuhanshu;
这样就可以运行了
从网上看了一个相近的例子希望能给大家一点帮助
恩我是这样解决的
create or replace procedure charuhanshu
as
cursor rt_cursor is select num,value1 from( select empno as num,sum(sal*12+nvl(comm,0)*12)as value1 from emp where empno in (select empno from emp)group by empno) ;
cc rt_cursor%rowtype;
begin
for cc in rt_cursor loop
insert into table2(id,num)values(cc.num,cc.value1);
end loop;
end charuhanshu;
这样就可以运行了
从网上看了一个相近的例子希望能给大家一点帮助
#1
游标只保存列名
insert into table2(id,num)values( rt_cursor.num, rt_cursor.value1);
insert into table2(id,num)values( rt_cursor.num, rt_cursor.value1);
#2
这个方法不行还是报错
15/52 PLS-00487: 对变量 'RT_CURSOR' 的引用无效
15/62 PL/SQL: ORA-00984: 列在此处不允许
15/4 PL/SQL: SQL Statement ignored
15/52 PLS-00487: 对变量 'RT_CURSOR' 的引用无效
15/62 PL/SQL: ORA-00984: 列在此处不允许
15/4 PL/SQL: SQL Statement ignored
#3
type r_cursor is ref cursor;
rt_cursor r_cursor;
10G及以上把这两句删了。
改成 rt_cursor sys_refcursor;
rt_cursor r_cursor;
10G及以上把这两句删了。
改成 rt_cursor sys_refcursor;
#4
问题解决了
恩我是这样解决的
create or replace procedure charuhanshu
as
cursor rt_cursor is select num,value1 from( select empno as num,sum(sal*12+nvl(comm,0)*12)as value1 from emp where empno in (select empno from emp)group by empno) ;
cc rt_cursor%rowtype;
begin
for cc in rt_cursor loop
insert into table2(id,num)values(cc.num,cc.value1);
end loop;
end charuhanshu;
这样就可以运行了
从网上看了一个相近的例子希望能给大家一点帮助
恩我是这样解决的
create or replace procedure charuhanshu
as
cursor rt_cursor is select num,value1 from( select empno as num,sum(sal*12+nvl(comm,0)*12)as value1 from emp where empno in (select empno from emp)group by empno) ;
cc rt_cursor%rowtype;
begin
for cc in rt_cursor loop
insert into table2(id,num)values(cc.num,cc.value1);
end loop;
end charuhanshu;
这样就可以运行了
从网上看了一个相近的例子希望能给大家一点帮助