cursor already open???????????pl/sql 5
CREATEorREPLACEPROCEDUREshow_unmarriedISv_namepresident.pres_name%type;v_birthpreside...
CREATE or REPLACE PROCEDURE show_unmarried
IS
v_name president.pres_name%type;
v_birth president.birth_yr%type;
cursor marriage_cursor IS
select pres_name, birth_yr
from president
where pres_name not in(
SELECT pres_name
from PRES_MARRIAGE)
order BY birth_yr;
marriage_rec marriage_cursor%ROWTYPE;
BEGIN
OPEN marriage_cursor;
FOR marriage_rec IN marriage_cursor LOOP
FETCH marriage_cursor INTO v_name,v_birth;
dbms_output.put_line(v_name||' '||v_birth);
end loop;
close marriage_cursor;
end;
----------------------------
创建没问题,可是每次调用的时候就出现
cursor already open的错误,很奇怪
请问怎么解决? 展开
IS
v_name president.pres_name%type;
v_birth president.birth_yr%type;
cursor marriage_cursor IS
select pres_name, birth_yr
from president
where pres_name not in(
SELECT pres_name
from PRES_MARRIAGE)
order BY birth_yr;
marriage_rec marriage_cursor%ROWTYPE;
BEGIN
OPEN marriage_cursor;
FOR marriage_rec IN marriage_cursor LOOP
FETCH marriage_cursor INTO v_name,v_birth;
dbms_output.put_line(v_name||' '||v_birth);
end loop;
close marriage_cursor;
end;
----------------------------
创建没问题,可是每次调用的时候就出现
cursor already open的错误,很奇怪
请问怎么解决? 展开
2个回答
展开全部
BEGIN
OPEN marriage_cursor;
FOR marriage_rec IN marriage_cursor LOOP
FETCH marriage_cursor INTO v_name,v_birth;
dbms_output.put_line(v_name||' '||v_birth);
end loop;
这个错误其实是因为你的cursor打开方式不对,顺序:begin open loop fetch into exit when notfound endloop close end;
OPEN marriage_cursor;
FOR marriage_rec IN marriage_cursor LOOP
FETCH marriage_cursor INTO v_name,v_birth;
dbms_output.put_line(v_name||' '||v_birth);
end loop;
这个错误其实是因为你的cursor打开方式不对,顺序:begin open loop fetch into exit when notfound endloop close end;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
OPEN marriage_cursor;
LOOP
FETCH marriage_cursor INTO v_name,v_birth;
EXIT WHEN marriage_cursor%NOTFOUND;
dbms_output.put_line(v_name||' '||v_birth);
end loop;
close marriage_cursor;
替换一下,这个是可以成功的。
LOOP
FETCH marriage_cursor INTO v_name,v_birth;
EXIT WHEN marriage_cursor%NOTFOUND;
dbms_output.put_line(v_name||' '||v_birth);
end loop;
close marriage_cursor;
替换一下,这个是可以成功的。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询