以下是该方案。 我有N个程序,每个程序都有不同的输入参数,我希望每个程序的执行时间都存储在xyz表中。
CREATE OR REPLACE PROCEDURE PROC_TIME_CAPTURE IS
before_procedure timestamp;
after_procedure timestamp;
actual_time number;
rpt_dt date;
BEGIN
select systimestamp into before_procedure from dual;
dbms_output.put_line (before_procedure );
proc_load('02/28/2013'); --- execution of procedure
select systimestamp into after_procedure from dual;
dbms_output.put_line (after_procedure);
select extract (second from (after_procedure-before_procedure)) into actual_time from dual;
dbms_output.put_line (actual_time);
END PROC_TIME_CAPTURE;
这就是我现在所做的事情。但我想让它充满活力。一次执行一个程序的insteag。我想将proc_name和date作为输入参数传递给主过程并执行它。
我是此网站的新用户,因此请在发布此查询时忽略任何错误或格式问题。
请指导我是否可以实现。
答案 0 :(得分:0)
您可以将您想要的过程调用作为字符串传递,然后使用EXECUTE IMMEDIATE执行它。
CREATE OR REPLACE PROCEDURE PROC_TIME_CAPTURE( p_procedure_call VARCHAR2 ) IS
before_procedure timestamp;
after_procedure timestamp;
actual_time number;
rpt_dt date;
BEGIN
select systimestamp into before_procedure from dual;
dbms_output.put_line (before_procedure );
EXECUTE IMMEDIATE p_procedure_call;
select systimestamp into after_procedure from dual;
dbms_output.put_line (after_procedure);
select extract (second from (after_procedure-before_procedure)) into actual_time from dual;
dbms_output.put_line (actual_time);
END PROC_TIME_CAPTURE;
您可以传递包含参数的完整过程调用。等...
BEGIN
PROC_TIME_CAPTURE( 'proc_load( ''20/10/2010'' )' );
END;