Error executing a Trigger ORA-04092: not possible on a trigger

Asked

Viewed 440 times

0

I have the following problem: - I’m not able to perform a job (Scheduling) after an Insert rescued by Trigger.

Row 2: ORA-04092: not possible on an ORA-06512 trigger: in "SYS.DBMS_ISCHED", line 135 ORA-06512: in "SYS.DBMS_SCHEDULER", line 271 ORA-06512: in "TRG_GET_LAST_INSERT", line 9

create or replace TRIGGER trg_get_last_insert
BEFORE INSERT
  ON TB_TOKEN
  FOR EACH ROW 

DECLARE
vToken NUMBER;

BEGIN

   SELECT ID INTO vToken FROM TB_TOKEN WHERE ID = ( SELECT MAX(ID) FROM TB_TOKEN );
   IF vToken IS NOT NULL THEN

        dbms_scheduler.create_job ( 
            job_name => 'TESTE_JOB', 
            job_type => 'PLSQL_BLOCK', 
            job_action => 'BEGIN 
                               DELETE FROM TB_TOKEN WHERE ID = ' + vToken + '
                            END;COMMIT;', 
            enabled => true, 
            start_date    => sysdate + 1/24,
            repeat_interval=> null
        ); 



   END IF;

END;

Does anyone know the best way to do that? The idea is to pass the parameter that is rescued and delete it after 1 hour.

  • tries to declare vToken as follows: vToken TB_TOKEN.ID%type;

  • @Lucasbrogni in which part of the code in the DECLARE ?

  • Where is vToken NUMBER; in the declare part.

  • Then @Lucasbrogni error is now conversion ORA-06502: PL/SQL: erro: character to number conversion error numérico ou de valor

  • 2

    Record the date of the operation , run the x job in x minutes and delete the records with more than 60 minutes , I think it is simpler.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.