在触发器ORACLE

时间:2015-07-17 19:58:14

标签: oracle dbms-scheduler

我的工作做得很好,但现在我需要在更新表时向他发送参数。 我在下面尝试此代码但不起作用:

   CREATE OR REPLACE TRIGGER "STK_PRUEBA"
   BEFORE INSERT OR UPDATE OR DELETE ON STK_TABLA
   REFERENCING OLD AS O
   NEW AS N
   FOR EACH ROW

   DECLARE
   sms varchar2(200);
   BEGIN  

   IF UPDATING THEN   
      --JOB
      SYS.DBMS_SCHEDULER.CREATE_JOB( job_name => 'ejemplo_job',
         job_type => 'EXECUTABLE',
         job_action => 'C:\WINDOWS\system32\cmd.exe',
         job_class => 'DEFAULT_JOB_CLASS',
         comments => 'Job to call batch script on Windows',
         auto_drop => FALSE,
         number_of_arguments => 4,
         enabled => FALSE);        
      ---Select
      select replace('Informa. Emision ' ||
         fd.tmovimiento || ' ' ||
         fd.fecha || ' Por: ' ||             
         trim(fd.moneda) || ' Venc:'   
      into sms
      from fin_tabla fd
      where fd.clave=:N.FIN_CLAVE;
      ---End Select
      SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE( job_name => 'ejemplo_job', argument_position => 1, argument_value => '/q'); 
      SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE( job_name => 'ejemplo_job', argument_position => 2, argument_value => '/c'); 
      SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE( job_name => 'ejemplo_job', argument_position => 3, argument_value => '"C:\job\ejemplo.bat"'); 
      SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE( job_name => 'ejemplo_job', argument_position => 4, argument_value => sms);    
      SYS.DBMS_SCHEDULER.ENABLE( 'ejemplo_job' ); 
      -- End Job
     END IF;
   END;

当我更新某个值时,它会显示以下错误:

  ORA-27486:privilegios insuficientes
  ORA-06512: en "SYS.DBMS_ISCHED", linea 124
  ORA-06512: en "SYS.DBMS_SCHEDULER", linea 271
  ORA-06512: en "AD.STK_TABLA", linea 6
  ORA-04088: errod durante la ejecucion del disparador AD.STK_PRUEBA"SYS.DBMS_ISCHED", linea 124

或者我如何将参数发送到JOB以供我选择?

0 个答案:

没有答案