Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Parallel Execute Stored Procedures Oracle

  • 04-06-2008 05:42PM
    #1
    Registered Users, Registered Users 2 Posts: 169 ✭✭


    Hi,

    Can someone point me in the the right direction of how i would go about executing stored procedures in parallel.

    For example:
    If i have 3 stored procedures, 2 that simply select from different tables and 1 procedure that executes both of these

    i.e.
    SP1 contains SELECT * FROM TABLEA
    and
    SP2 contains SELECT * FROM TABLEB

    and SP3 simply calls both of the above eg
    begin
    Exec SP1;
    Exec SP2;
    end;

    Is it possible to get sp3 to NOT wait for SP1 to finish before executing SP2. i.e execute SP1 then immediately execute SP2 almost
    like spawning in separate processes.
    I suppose a manual way of achieving this would be to open SQL Plus and execute SP1 then open a second sql plus session and execute
    sp2 creating the situation were both are executing in parallel.
    I need to find a way of performing this within SP3.

    Cheers, DB


Comments

  • Registered Users, Registered Users 2 Posts: 23,202 ✭✭✭✭Tom Dunne


    Off the top of my head, no, not the way you are doing it.

    One way is to have sp1 and sp2 in two separate schemas. I doubt that is what you want.

    To the best of my knowledge, pl/SQL does not do threads or parallel execution.


  • Registered Users, Registered Users 2 Posts: 9,585 ✭✭✭DublinWriter


    Try the asktom website.


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    Have a look at dbms_job.submit


  • Registered Users, Registered Users 2 Posts: 169 ✭✭DonnieBrasco


    thanks all.

    dbms_job.submit - excellent!
    In my sample case above, this is the usage.

    create sp1 and sp2 to do whatever.
    then

    CREATE OR REPLACE PROCEDURE SP3
    AS

    v_JobNum NUMBER := 1;

    BEGIN


    BEGIN
    DBMS_JOB.SUBMIT(v_JobNum,'SP1;',sysdate,'sysdate +1');

    v_JobNum := v_JobNum + 1;

    DBMS_JOB.SUBMIT(v_JobNum,'SP2;',sysdate,'sysdate +1');

    COMMIT;
    END;

    END SP3;


Advertisement