Passing a variable to DBMS Parallel Execute SQL Statement

385 Views Asked by At
/*FOO Process Variables*/
    l_chunk_sql            VARCHAR2(1000);
    l_sql_stmt varchar2(1000);
    v_date               DATE := trunc(sysdate) + 5; 
    v_order_time           VARCHAR2(200) := 'AFTERNOON'; 
    v_flag          VARCHAR2(1) := 'N';


BEGIN
    /*Create chunks by store*/
    l_chunk_sql := 'SELECT distinct loc_nbr, loc_nbr FROM location where close_date is null ';
dbms_parallel_execute.create_task('PROCESS PREPAREDATA');
    dbms_parallel_execute.create_chunks_by_sql('PROCESS PREPAREDATA', l_chunk_sql, false);
    dbms_parallel_execute.run_task(task_name => 'PROCESS PREPAREDATA',
    sql_stmt => 'begin preparedata( :start_id, :end_id, v_date ,v_order_time,v_flag); end;',
    language_flag => dbms_sql.native, parallel_level => 10);

   dbms_parallel_execute.drop_task('PROCESS PREPAREDATA');
END;

Variables v_date,v_order_date,v_flag not getting recognized. Any help please

1

There are 1 best solutions below

1
On

Those variables are declared out of scope of that statement, so - how about concatenating them?

sql_stmt => 'begin preparedata( :start_id, :end_id, ' || v_date ||',' || v_order_time ||','|| v_flag || '); end;',