0
votes

I have a procedure which is being called at server side and I need to make it asynchronous.

So I have created another proc in which I'll create Oracle'Job and this will call that proc in its job_action. Proc is:

  PROCEDURE upload_csv_file_data(a_what_to_do IN VARCHAR2,
                             a_logon_user IN VARCHAR2,
                             a_csv_data IN CLOB)
  IS
    v_job_action  VARCHAR2(32676);
    /*v_log_error   VARCHAR2(32676);*/
    v_job_name    VARCHAR2(100);
  BEGIN

    v_job_action := 'process_csv_file_data(''' || a_what_to_do || ''',''' || a_logon_user || ''',' || a_csv_data || ');';
    v_job_name    := 'UPLOAD_CSV_FILE_DATA';



    sys.dbms_scheduler.create_job(
        job_name => v_job_name,
        job_type => 'PLSQL_BLOCK',
        job_action => 'begin ' || v_job_action || ' EXCEPTION WHEN OTHERS THEN NULL; end;',
        start_date => SYSTIMESTAMP,
        job_class => 'BATCH_CLASS',
        comments => 'Start uplaoding CSV file data.',
        auto_drop => TRUE,
        enabled => TRUE);

  END;

Proc which needs to be called IN JOB is:

    CREATE OR REPLACE PROCEDURE process_csv_file_data(a_what_to_do IN VARCHAR2,
                                 a_logon_user IN VARCHAR2,
                                 a_csv_data IN CLOB)
    IS
    .
       /*STEPS*/
    .
    END;

But since one of the passing parameters for this PROC is CLOB hence whenever I'm trying to call is PROC using in JOB it throws an error "ORA-06502: PL/SQL: numeric or value error".

As job_action datatype is of VARCHAR2(4000); and hence the moment CLOB datatype is dynamically passed while calling the proc in the Job action it throws an error "ORA-06502: PL/SQL: numeric or value error"

Kindly suggest on this. (can we pass the parameters using bind variables?)

2

2 Answers

0
votes

The CLOB data has to come from somewhere. Instead of passing it as a parameter to the procedure you should stash it in a table which the job can read. Alternatively could you read the original source as a file, ideally as an external table, or as a BFILE.

0
votes

SYSTIMESTAMP returns a TIMESTAMP WITH TIME ZONE value, so FROM_TZ(SYSTIMESTAMP, 'US/Eastern') is useless and it actually should return an error.

Data type of job_action is VARCHAR2, i.e. up to 32K characters, so CLOB is not possible.

Like APC I recommend a BFILE or an external table for processing.