按顺序执行多个过程的存储过程 [英] Stored procedure to execute multiple procedures in a sequential order

查看:731
本文介绍了按顺序执行多个过程的存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过在DBMS_Scheduler中进行调度,按顺序运行多个pl sql过程。我们可以通过调用所有这些proc来运行顺序顺序创建主进程来完成它,如果任何proc失败,执行就会停止

我还想捕获异常处理吗?



我尝试过:



创建或替换


程序RUN_JOBS AS



BEGIN



PROCEDURE1 ;



PROCEDURE2;



PROCEDURE3;



PROCEDURE4;



程序5;



例外



当其他人的时候



dbms_output.put_line('error ::'|| SQLERRM);



err_num:= SQLCODE;



err_msg:= SUBSTR(SQLERRM,1,100);



插入tmp_log(no,err_message)值(1,SQLERRM);



END;



/

解决方案

您可以简单地创建一个SQL作业并将这些步骤添加到作业中并执行其中的存储过程。对于错误处理,您可以使用try&捕获存储过程本身。

具有步骤的作业,以便您可以管理,如果之前的步骤失败,则停止执行后续步骤。


I have a requirement to run multiple pl sql procedures in a sequential order by scheduling in DBMS_Scheduler. Can we accomplish it by creating main proc by calling all these procs to run sequential order and the execution gets stopped if any of the proc gets failed
Also i'd like to capture the exception handling as well?

What I have tried:

CREATE OR REPLACE

PROCEDURE RUN_JOBS AS

BEGIN

PROCEDURE1;

PROCEDURE2;

PROCEDURE3;

PROCEDURE4;

PROCEDURE5;

exceptions

when others then

dbms_output.put_line('error::'||SQLERRM);

err_num := SQLCODE;

err_msg := SUBSTR(SQLERRM, 1, 100);

insert into tmp_log (no,err_message) values(1,SQLERRM);

END;

/

解决方案

You can simply create a SQL Job and add the steps into jobs and execute the Stored procedure in that. For error handling, you can use try & catch inside the stored procedure itself.
Job having steps so you can manage like if previous steps failed the stop executing the next steps.


这篇关于按顺序执行多个过程的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆