1

我有一个调度程序,它运行需要输入参数的存储过程。

BEGIN
  DBMS_SCHEDULER.DROP_PROGRAM
    (program_name          => 'MYSCHEMA.EXPORT_SCHEMA_STARTING');
END;
/
BEGIN
  SYS.DBMS_SCHEDULER.CREATE_PROGRAM
    (
      program_name         => 'MYSCHEMA.EXPORT_SCHEMA_STARTING'
     ,program_type         => 'STORED_PROCEDURE'
     ,program_action       => 'MYSCHEMA.EXPORT_STATUS'
     ,number_of_arguments  => 0
     ,enabled              => FALSE
     ,comments             => NULL
    );

  SYS.DBMS_SCHEDULER.ENABLE
    (name                  => 'MYSCHEMA.EXPORT_SCHEMA_STARTING');
END;
/

我想知道如何将参数传递给 EXPORT_STATUS 过程

4

2 回答 2

1

您应该能够使用传递参数DEFINE_PROGRAM_ARGUMENT

BEGIN

  DBMS_SCHEDULER.CREATE_PROGRAM(
      program_name         => 'MYSCHEMA.EXPORT_SCHEMA_STARTING'
     ,program_type         => 'STORED_PROCEDURE'
     ,program_action       => 'MYSCHEMA.EXPORT_STATUS'
     ,number_of_arguments  => 1
     ,enabled              => FALSE
     ,comments             => NULL
    );

DBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT (
   program_name            => 'MYSCHEMA.EXPORT_SCHEMA_STARTING',
   argument_position       => 1,
   argument_name           => 'STATUS',
   argument_type           => 'VARCHAR2',
   default_value           => 'STARTING');

  DBMS_SCHEDULER.ENABLE
    (name                  => 'MYSCHEMA.EXPORT_SCHEMA_STARTING');
END;
于 2013-05-14T07:10:46.347 回答
0

到目前为止,我将其更改为运行 PLSQL BLOCK 的程序

BEGIN
  SYS.DBMS_SCHEDULER.CREATE_PROGRAM
    (
      program_name         => 'MYSCHEMA.EXPORT_SCHEMA_STARTING'
     ,program_type         => 'PLSQL_BLOCK'
     ,program_action       => 'MYSCHEMA.EXPORT_STATUS(''STARTING''); END;'
     ,number_of_arguments  => 0
     ,enabled              => FALSE
     ,comments             => NULL
    );

  SYS.DBMS_SCHEDULER.ENABLE
    (name                  => 'MYSCHEMA.EXPORT_SCHEMA_STARTING');
END;
/

它按我的预期工作。但如果有人知道如何保持以前的格式,将不胜感激。

于 2013-05-14T03:39:37.067 回答