使用DBMS_SCHEDULER.SET_JOB_ANYDATA_VALUE
并传递封装在BLOB
值中的ANYDATA
时,分配失败并出现错误:
ORA-22370: incorrect usage of method
ORA-06512: at "SYS.DBMS_ISCHED", line 278
ORA-06512: at "SYS.DBMS_SCHEDULER", line 880
ORA-06512: at line 9
22370. 00000 - "incorrect usage of method %s"
*Cause: This method of SYS.AnyType or SYS.AnyData or SYS.AnyDataSet is
being used inappropriately.
*Action: Check the documentation for correct usage.
如果我通过封装在VARCHAR2
中的ANYDATA
,它可以工作,但是BLOB
不起作用。这是一个示例:
PL / SQL程序
CREATE OR REPLACE PROCEDURE BLOB_TEST (
p_blob BLOB
) AS
BEGIN
COMMIT;
END;
/
DBMS程序
BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => 'prog_blob_test',
program_type => 'STORED_PROCEDURE',
program_action => 'BLOB_TEST',
number_of_arguments => 1,
enabled => FALSE
);
DBMS_SCHEDULER.DEFINE_ANYDATA_ARGUMENT (
program_name => 'prog_blob_test',
argument_name => 'p_blob',
argument_position => 1,
argument_type => 'BLOB',
default_value => NULL
);
DBMS_SCHEDULER.ENABLE (name => 'prog_blob_test');
END;
/
DBMS作业
DECLARE
l_blob BLOB := UTL_RAW.cast_to_raw('This is some BLOB data');
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'job_blob_test',
program_name => 'prog_blob_test'
);
DBMS_SCHEDULER.SET_JOB_ANYDATA_VALUE (
job_name => 'job_blob_test',
argument_name => 'p_blob',
argument_value => SYS.ANYDATA.ConvertBlob(l_blob) -- DON'T WORK
-- argument_value => SYS.ANYDATA.convertvarchar2('test') -- WORKS!
);
-- DBMS_SCHEDULER.ENABLE (name => 'job_blob_test');
END;
/
答案 0 :(得分:0)
尝试简单地使用DEFINE_PROGRAM_ARGUMENT而不是SET_JOB_ANYDATA_VALUE:
declare
l_blob BLOB := UTL_RAW.cast_to_raw('This is some BLOB data');
begin
dbms_scheduler.CREATE_PROGRAM
(
program_name => 'prog_blob_test',
program_action => 'BLOB_TEST',
program_type => 'STORED_PROCEDURE',
number_of_arguments => 1,
enabled => FALSE
) ;
dbms_scheduler.DEFINE_PROGRAM_ARGUMENT
(
program_name => 'prog_blob_test',
argument_position => 1,
argument_type => 'BLOB',
default_value => l_blob
);
DBMS_SCHEDULER.ENABLE(name => 'prog_blob_test');
end;
/
这应该适用于任何SQL数据类型。