I am trying to create a scheduled job in Oracle DB, from which, I need to execute a stored procedure.
I have created the procedure like:
CREATE OR REPLACE PROCEDURE "delete_old_transactions" AS
BEGIN
DELETE from EVENT_JOURNAL where EVENT_JOURNAL.WRITE_TIMESTAMP < (((SYSDATE-CAST(TO_TIMESTAMP_TZ('01-01-1970 00:00:00+00:00', 'DD-MM-YYYY HH24:MI:SS TZH:TZM') as date)) * 24 * 60 * 60 * 1000) - (4 * 24 * 60 * 60 * 1000));
DELETE from SNAPSHOT where SNAPSHOT.CREATED < (((SYSDATE-CAST(TO_TIMESTAMP_TZ('01-01-1970 00:00:00+00:00', 'DD-MM-YYYY HH24:MI:SS TZH:TZM') as date)) * 24 * 60 * 60 * 1000) - (4 * 24 * 60 * 60 * 1000));
END;
The stored procedure compiles fine and gets created successfully.
I created the scheduled job like:
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'delete_old_transactions_job',
job_type => 'STORED_PROCEDURE',
start_date => SYSTIMESTAMP,
enabled => true,
job_action => 'delete_old_transactions',
repeat_interval => 'FREQ=MINUTELY;INTERVAL=2;',
job_class => 'DEFAULT_JOB_CLASS',
comments => 'Job for deleting old transactions.');
END;
The scheduled job also gets created and is executing after every 2 minutes as desired, but it is failing in the execution and returns an error:
ORA-06576: not a valid function or procedure name.