set serveroutput on
declare
cursor c_kk is
select name
from s_customer
where s_customer.region_id=s_dept.region_id
and region_id=(select region_id from s_dept where name='Sales');
c_kk s_customer.name%type;
begin
open c_kk;
loop
fetch c_kk into ckk;
exit when c_name1%notfound;
dbms_output.put_line(ckk);
end loop;
close c_kk;
end;
/这是我写的一个pl sql代码。用动态光标写。
有两个表,s_dept和s_customer。
他们有一个相同的项region_id。
现在我想打印s_customer表里的name项,条件是s_dept表中的name叫peter。这是错误报告。
cursor c_kk is
*
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00305: previous use of 'C_KK' (at line 7) conflicts with this use
ORA-06550: line 2, column 1:
PL/SQL: Item ignored
ORA-06550: line 9, column 6:
PLS-00456: item 'C_KK' is not a cursor
ORA-06550: line 9, column 1:
PL/SQL: SQL Statement ignored
ORA-06550: line 11, column 7:
PLS-00456: item 'C_KK' is not a cursor
ORA-06550: line 11, column 1:
PL/SQL: SQL Statement ignored
ORA-06550: line 12, column 11:
PLS-00201: identifier 'C_NAME1' must be declared
ORA-06550: line 12, column 1:
PL/SQL: Statement ignored
ORA-06550: line 13, column 22:
PLS-00201: identifier 'CKK' must be declared
ORA-06550: line 13, column 1:
PL/SQL: Statement ignored
ORA-06550: line 15, column 7:
PLS-00456: item 'C_KK' is not a cursor
ORA-06550: line 15, column 1:
PL/SQL: SQL Statement ignored