加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle执行存储过程报错:ORA-12011

发布时间:2020-12-12 14:39:35 所属栏目:百科 来源:网络整理
导读:执行定时任务时报错: 不一定是权限问题,但肯定是存储过程执行的问题。 我的存储过程带参数,我用测试存储过程的代码放入了job的what值,eg:proc_update_tag_cor_id(v_cor=:v_cor v_tag=:v_tag ); 执行时没有传入参数值,所以执行不通过。 修改存储过程后

执行定时任务时报错:






不一定是权限问题,但肯定是存储过程执行的问题。
我的存储过程带参数,我用测试存储过程的代码放入了job的what值,eg:proc_update_tag_cor_id(v_cor=>:v_cor
v_tag=>:v_tag
);


执行时没有传入参数值,所以执行不通过。

修改存储过程后(存储过程内部参数可以定义在执行过程中),就可以了

附:

我的存储过程代码:

原来的:

create or replace procedure proc_update_tag_cor_id(
c_course out sys_refcursor,
v_tag_id in out edc_tag_course.id%type,
v_cor_id in out edc_course.id%type)
AUTHID CURRENT_USER
is
begin
--查询“最新上市”tag的id
select t.id into v_tag_id from edc_tag_course t where t.tag_name = '最新上市';

if v_tag_id is null then
dbms_output.put_line('“最新上市”标签不存在');
return;
else
dbms_output.put_line('“最新上市”tagId is: '|| v_tag_id);
end if ;
--删除关联的最新课程
delete from ( select * from edc_tag_course_id where tag_id= v_tag_id);
--打开游标,获得最新课程的结果集
open c_course for
select t.id from (select id from edc_course order by create_time desc ) t where rownum <=5;
--提取游标值
fetch c_course into v_cor_id;


while c_course %found loop
dbms_output.put_line('new courses id is: '|| v_cor_id);
insert into edc_tag_course_id values(sys_guid(),v_cor_id,v_tag_id);
fetch c_course into v_cor_id;
end loop;
--关闭游标
close c_course;
commit;
end proc_update_tag_cor_id;

现在的:

create or replace procedure proc_update_tag_cor_id AUTHID CURRENT_USER is c_course sys_refcursor; v_tag_id edc_tag_course.id%type; v_cor_id edc_course.id%type; begin --查询“最新上市”tag的id select t.id into v_tag_id from edc_tag_course t where t.tag_name = '最新上市'; if v_tag_id is null then dbms_output.put_line('“最新上市”标签不存在'); return; else dbms_output.put_line('“最新上市”tagId is: '|| v_tag_id); end if ; --删除关联的最新课程 delete from ( select * from edc_tag_course_id where tag_id= v_tag_id); --打开游标,获得最新课程的结果集 open c_course for select t.id from (select id from edc_course order by create_time desc ) t where rownum <=5; --提取游标值 fetch c_course into v_cor_id; while c_course %found loop dbms_output.put_line('new courses id is: '|| v_cor_id); insert into edc_tag_course_id values(sys_guid(),v_tag_id); fetch c_course into v_cor_id; end loop; --关闭游标 close c_course; commit; end proc_update_tag_cor_id;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读