Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL Package/Procedure Question (11g Release 2 Windows)
PL/SQL Package/Procedure Question [message #602486] Wed, 04 December 2013 16:02 Go to next message
Duane
Messages: 557
Registered: December 2002
Senior Member
Not sure if this can be done or not so that's why I'm asking.

Is there a way to have a Package with a Procedure that runs a process/query but returns back to the client right away?

CREATE OR REPLACE PACKAGE Test is

  procedure Quick;

end Test;

CREATE OR REPLACE PACKAGE BODY Test as

  procedure Quick (Parameter1 in  varchar2,
                   Response   out varchar2) is

    begin

      Insert into a table that takes longer than 3 minutes.  Something that takes a long time to process.

      Response := 'Your report is running.';

    end;

end Test;



So, the client has a time out of 2 minutes but the Procedure runs for more than 3 minutes. Is there a way to call the Procedure and have it return back to the client with some message but have the meat of the Procedure processing away in the Database without having to wait for the Procedure to complete?

I figured this could be done with the Procedure calling a DBMS_JOB to handle the big load but I thought maybe there is a better way of doing this within the actual Procedure. Maybe some statement that performs the work but immediately returns back to the client.
Re: PL/SQL Package/Procedure Question [message #602487 is a reply to message #602486] Wed, 04 December 2013 16:06 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Is there a way to have a Package with a Procedure that runs a process/query but returns back to the client right away?
No, no way
Re: PL/SQL Package/Procedure Question [message #602488 is a reply to message #602487] Wed, 04 December 2013 16:14 Go to previous messageGo to next message
Duane
Messages: 557
Registered: December 2002
Senior Member
Ok, thanks. I kind of figured that but it never hurts to ask.
Re: PL/SQL Package/Procedure Question [message #602498 is a reply to message #602486] Thu, 05 December 2013 00:17 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Duane wrote on Thu, 05 December 2013 03:32

Is there a way to have a Package with a Procedure that runs a process/query but returns back to the client right away?


If you are looking for something such that the client gets the first row before function generates the last row then have a look at Pipelined functions
Re: PL/SQL Package/Procedure Question [message #602511 is a reply to message #602486] Thu, 05 December 2013 02:42 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
You can get the effect you want by running the procedure through the scheduler:
orclz>
orclz> create or replace procedure slow_proc as begin
  2  dbms_lock.sleep(60);
  3  end;
  4  /

Procedure created.

orclz> exec dbms_scheduler.create_job(job_name=>'run_now',-
> job_type=>'stored_procedure',-
> job_action=>'slow_proc',-
> enabled=>true)

PL/SQL procedure successfully completed.

orclz> select JOB_NAME,ELAPSED_TIME from user_scheduler_running_job
  2  ;
select JOB_NAME,ELAPSED_TIME from user_scheduler_running_job
                                  *
ERROR at line 1:
ORA-00942: table or view does not exist


orclz> select JOB_NAME,ELAPSED_TIME from user_scheduler_running_jobs;

JOB_NAME
----------------------------------------------------------------------------
ELAPSED_TIME
---------------------------------------------------------------------------
RUN_NOW
+000 00:00:23.24


orclz> select JOB_NAME,ELAPSED_TIME from user_scheduler_running_jobs;

JOB_NAME
----------------------------------------------------------------------------
ELAPSED_TIME
---------------------------------------------------------------------------
RUN_NOW
+000 00:00:35.81


orclz>


Re: PL/SQL Package/Procedure Question [message #602546 is a reply to message #602511] Thu, 05 December 2013 09:25 Go to previous message
Duane
Messages: 557
Registered: December 2002
Senior Member
Thanks. I figured it would have to be some type of scheduled job.
Previous Topic: Need Fuzzy logic with Regular expression query
Next Topic: How to populate data from an Excel file to Oracle table's LOB column
Goto Forum:
  


Current Time: Thu Apr 25 19:31:20 CDT 2024