我有以下过程,但没有创建调度程序作业,我在运行作业时找不到任何错误。我该如何调试这个以及代码有什么问题?
CREATE OR REPLACE PROCEDURE test
IS
prod_no varchar2(32);
prod_date date;
employee varchar2(32);
assurer varchar2(32);
prod_description varchar2(32);
prod_days number;
assig varchar2(32);
reg_no number;
l_v number;
BEGIN
prod_no := '300';
prod_date := sysdate;
employee := 'SAM';
assurer := 'MAT';
prod_description := 'test';
prod_days := 1;
assig := 'A';
reg_no := 1;
DBMS_SCHEDULER.create_job (
job_name => DBMS_SCHEDULER.generate_job_name ('FR'),
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN test_job('
|| i_prod_no
|| ','''
|| prod_date
|| ','''
|| employee
|| ','''
|| assurer
|| ','''
|| prod_description
|| ','''
|| prod_days
|| ','''
|| assig
|| ','''
|| reg_no
|| '''); end;',
start_date => SYSDATE,
end_date => NULL,
enabled => TRUE,
comments => 'test product'
);
commit;
exception
when others then
dbms_output.put_line (dbms_utility.format_error_stack);
END test;
/
答案 0 :(得分:3)
如果工作操作在语法上不正确,您将不会收到任何警告,但您也不会找到工作。 以下是您的发言:
BEGIN test_job(300,'04-OCT-12,'SAM,'MAT,'test,'1,'A,'1'); end;
你缺少一些'来关闭字符串值。
CREATE OR REPLACE PROCEDURE test
IS
prod_no varchar2(32);
prod_date date;
employee varchar2(32);
assurer varchar2(32);
prod_description varchar2(32);
prod_days number;
assig varchar2(32);
reg_no number;
l_v number;
l_statement varchar2(32767);
BEGIN
prod_no := '300';
prod_date := sysdate;
employee := 'SAM';
assurer := 'MAT';
prod_description := 'test';
prod_days := 1;
assig := 'A';
reg_no := 1;
l_statement := 'BEGIN test_job('
|| i_prod_no
|| ','''
|| prod_date
|| ','''
|| employee
|| ','''
|| assurer
|| ','''
|| prod_description
|| ','''
|| prod_days
|| ','''
|| assig
|| ','''
|| reg_no
|| '''); end;'
dbms_output.put_line(l_statement);
DBMS_SCHEDULER.create_job (
job_name => DBMS_SCHEDULER.generate_job_name ('FR'),
job_type => 'PLSQL_BLOCK',
job_action => l_statement,
start_date => SYSDATE,
end_date => NULL,
enabled => TRUE,
comments => 'test product'
);
commit;
exception
when others then
dbms_output.put_line (dbms_utility.format_error_stack);
END test;
/