0

我正在使用 Oracle 10g 并使用以下脚本来创建作业

CREATE OR REPLACE PROCEDURE archtemp AS
BEGIN
    UPDATE ARCH_TEMP SET ARCH_DATE = SYSDATE; 
    COMMIT;
END archtemp;

VAR jobno NUMBER;
BEGIN
   DBMS_JOB.SUBMIT(:jobno, 'archtemp;', SYSDATE, 'sysdate + 1/1440');
   COMMIT;
END;

该作业永远不会自动执行(尽管它是手动运行的),并出现以下错误alert_sid.log

ORA-12012: error on auto execute of job 26
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 8

我无法将 ORA-01422 错误与我的任何代码相关联。我fetch这里什么也不做。

4

5 回答 5

1

假设这是一个 SQL*Plus 的脚本,有两个 / 缺失,所以它什么都不做:

CREATE OR REPLACE PROCEDURE archtemp AS
BEGIN
    UPDATE ARCH_TEMP SET ARCH_DATE = SYSDATE; 
    COMMIT;
END archtemp;
/

VAR jobno NUMBER;
BEGIN
   DBMS_JOB.SUBMIT(:jobno, 'archtemp;', SYSDATE, 'sysdate + 1/1440');
   COMMIT;
END;
/

我猜这是另一份工作失败了,不是你的。

于 2010-09-08T09:03:47.720 回答
0

I'd use a SERVERERROR trigger (as described here) to try to catch the statement that is failing. But first, you could check the alert log. If recursive SQL is erroring, there may be a problem in the data dictionary.

于 2010-09-09T01:02:22.080 回答
0

我也尝试了 Nick Pierpoint 的解决方案,但它对我不起作用 LUCK 看起来有问题,因为我在另一台具有 Oracle 9i 的机器上尝试了同样的事情,但它失败了!!!

谢谢大家的回复。

问候

于 2010-09-14T13:15:23.710 回答
0

您在这里不进行任何数据提取,但我猜可能会在表上触发一些ON UPDATE触发器。ARCH_TEMP核实。

于 2010-09-08T09:03:29.897 回答
0

Try putting in an explicit PL/SQL block as the WHAT parameter.

dbms_job.submit(v_jobno, 'begin archtemp; end;', sysdate, 'sysdate+1/1440');

Here's my test case, which seems to work fine:

create table arch_temp (
    arch_date date
    );

-- create row to test update
insert into arch_temp (arch_date) values (null);

create or replace procedure archtemp as
begin
    update arch_temp set arch_date = sysdate;
    commit;
end archtemp;
/

-- test everything works in isoloation

begin 
    archtemp; 
end;
/

select * from arch_temp;
-- arch_date = 10:49:34

select * from user_jobs;
-- no rows returned

declare
    v_jobno number;
begin
    dbms_job.submit(v_jobno, 'begin archtemp; end;', sysdate, 'sysdate+1/1440');
    commit;
    dbms_output.put_line('v_jobno: ' || to_char(v_jobno));
end;
/

-- dbms_output...
-- v_jobno: 50520

select * from user_jobs;

-- JOB 50520 returned
-- LAST_DATE = 10:51:11

select * from arch_temp;

-- ARCH_DATE = 10:51:11
于 2010-09-09T09:57:01.497 回答