Submitting job from a procedure
Hi,
I need to submit a job and call it frm a procedure. I need to run the job exactly at 12 in the midnight. How will i pass the start_time to the job? the problem i face here is the procedure can be called on any date. following is the procedure
CREATE OR REPLACE PROCEDURE JOBS(DT NUMBER)
AS
L_JOB NUMBER;
BEGIN
FOR I IN (SELECT JOB FROM USER_JOBS WHERE WHAT LIKE 'SPARCHIVE%')
LOOP
DBMS_JOB.REMOVE(I.JOB);
END LOOP;
DBMS_JOB.SUBMIT(L_JOB, 'SPARCHIVE('||DT||');', SYSDATE , 'sysdate+1');
commit;
END;
/pls help me how to do it.
Thanks
Muneer
Current date and time
SQL> SELECT to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') FROM dual;
TO_CHAR(SYSDATE,'DD-
18-OCT-2004 13:13:09the previous midnight...
SQL> SELECT to_char(trunc(sysdate), 'DD-MON-YYYY HH24:MI:SS') FROM dual;
TO_CHAR(TRUNC(SYSDAT
18-OCT-2004 00:00:00the next midnight...
SQL> SELECT to_char(trunc(sysdate+1), 'DD-MON-YYYY HH24:MI:SS') FROM dual;
TO_CHAR(TRUNC(SYSDAT
19-OCT-2004 00:00:00Okay?
Cheers, APC
Similar Messages
-
Problem while submitting job from Forms
Hi,
i'm submitting a job in when button pressed trigger. This job will call a Backend Package(one procedure). But the job id is created in the backend but the job is not running. but if i run the job with DBMS_job.Run(jobid) from form itself after submitting the job, its working fine. Do we need to maintain any parameter to run job automatically?
Thanks in advance.if there are four parameters passed then one of them is contradicting ur conditional statements. First check and debug those parameters if they consist the required value. also post ur code for further scrutiny.
zaibi. -
Submitting QLTTRAMB from SQL Procedure
Hi,
Could someone suggest the methodology to submit the Collection Import Manager (QLTTRAMB) from a stored procedure using fnd_request.submit_request? I would like to know what manadatory params need to be supplied with data for the request submission. Any pointers to a doc is much appreciated.
Thanks
Edited by: user8880997 on Dec 8, 2010 9:22 AMThanks for the inputs. Even when submitting the Collection Import Manager, I get the request id = 0. So it is not submitting the pgm in the first place. Here is how I am submitting the request from a standalone anonymous PL/SQL block. Am I doing something wrong?
BEGIN
v_req_id :=
fnd_request.submit_request (application => 'QA', -- Appln Short Name
program => 'QLTTRAMB', -- Program Short Name
description => 'Collection Imp Pgm '||'MST',
start_time => NULL,
sub_request => FALSE,
argument1 => '1', ---- No of worker rows/ processing threads
argument2 => '1', -- 1 means Insert, 2 means Update
argument3 => 46633, --User ID submitting the request
argument4 => 'No' -- Gather Stats on QA_RESULTS_INTERFACE (Yes/ No)
COMMIT;
DBMS_OUTPUT.put_line ('Req ID: ' || v_req_id);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error: ' || SQLERRM);
END;
Thanks -
Submitting Job with parameterised procedure using DBMS_JOB
Hi,
I need to submit a job which makes a call to a procedure with parameters as shown below:
PROCDURE SUB_JOB ( P_PAR1 VARCHAR2, P_PAR2 VARCHAR2)
IS
L_JOBID INTEGER;
BEGIN
DBMS_JOB.SUBMIT ( L_JOBID, ' BEGIN PROC1 ('''||P_PAR1||''','''||P_PAR2||'''); END;' );
COMMIT;
END;
But when I execute the above procedure I get the error like below:
PLS-00103: Encountered the symbol ")" when expecting one of the following: ( - + case mod new not null others <an identifier> avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe <an alternatively-quoted string literal with character set specification> <an alternatively-q
I checked many examples but all are with hard coded values. In this I will know the values of parameters to PROC1 only at run time.
Is there any other way of doing this. I'm using Oracle 10g. Please advise.
Thanks. PatWorks for me...
SQL>create or replace procedure p(p_par1 number, p_par2 number)
2 as
3 begin
4 null;
5 end;
6 /
Procedure created.
SQL>declare
2 p_par1 number;
3 p_par2 number;
4 L_JOBID INTEGER;
5 begin
6 DBMS_JOB.SUBMIT ( L_JOBID, ' BEGIN P ('''||P_PAR1||''','''||P_PAR2||'''); END;');
7 end;
8 /
PL/SQL procedure successfully completed.Message was edited by:
SamB -
Hi !
After hours of hard work, i got my agent up and running,
(fixing ownership of files etc.)and was pleased to see the auto-
discover function working properly. But... when trying to submit
a job, it failed with the message "error processing the job que".
I am using OEM 1.4.
Will it help to upgrade to OEM 1.X ?
John
nullHi!
I'm using OEM 1.6, but I get a similar message: "error accessing
job queue"...
Using Oracle 8.0.5 (shipping), with SuSe 5.3.
Any help would be appreciate,
Thomas
John S. Henriksen (guest) wrote:
: Hi !
: After hours of hard work, i got my agent up and running,
: (fixing ownership of files etc.)and was pleased to see the
auto-
: discover function working properly. But... when trying to
submit
: a job, it failed with the message "error processing the job
que".
: I am using OEM 1.4.
: Will it help to upgrade to OEM 1.X ?
: John
null -
Removing JOB From the Queue once executed
How do you submit a job so that it runs only once and then gets removed from the Jobs Queue ?
I am submitting a Job from a procedure and I want the job to be removed once it is run. Can the Procedure that is called in the DBMS_JOB.SUBMIT(...) call contain a line such as DBMS_JOB.REMOVE(JobID)? How will the procedure know what the JobID for that job is ?
Thanks.Just don't specify a NEXT_DATE or INTERVAL (just use the first two arguments, JOB and WHAT) and that's exactly what will happen.
Richard -
Problem in submitting job through Pl/sql
Hi,
I have a procedure with parameters as shown below.
Pkg1.Proc1(indate date, innum1 number, innum2 number)
I am trying to execute this procedure by submitting jobs through another procedure and passing the parameters dynamically. I found the jobs are not getting submitted. Please see the code inside the procedure as below.
dbms_job.submit(var1,'BEGIN pkg1.Proc1(''' || i_date||''','|| i_num1||','||i_num2||'); END;',SYSDATE);
I have tried as following also
dbms_job.submit(var1,'BEGIN pkg1.Proc1(''''' || i_date||''''','|| i_num1||','||i_num2||'); END;',SYSDATE);
both time the procedure is running fine but the job is not seen as submitted.
when I am executing it as follows in sql * plus, it is executing fine.
dbms_job.submit(var1,'BEGIN pkg1.Proc1(''15-aug-2007'',1,2); END;',SYSDATE);
Please let me know if I need to change anything in my code.
Regards,
PouloseHi Pls find the portion below.
process_id is of type number and having value 1001. v_business_dt is a date variable. and i_module is a number with value 1.
DBMS_JOB.ISUBMIT(CF_CRM.process_id,'BEGIN DBK_CRM_PROCESS_TRACKING.RUN_PROC(''' || v_business_dt||''','|| i_module||','||CF_CRM.process_id||'); END;',SYSDATE); -
Submitting xml publisher not producing output file when submiting from Oracle Procedure
When Running XML publisher program from Oracle Procedure, Program not generating output file, but same XML publisher program running from Concurrent program runs and produces the output file.
Here is the code
CREATE OR REPLACE PROCEDURE apps.wmmgd_sepa_formats (
p_return_msg OUT VARCHAR2,
p_return_code OUT NUMBER,
p_payment_batch IN VARCHAR2 ---,
--- p_bank_name in varchar2
IS
name: wmmgd_sepa_formats
purpose: this procedureis to create SEPA payment formats
revisions:
ver date author description
1.0 6/11/2013 V Gongireddy Created the Procedure
l_ret BOOLEAN;
l_req_id NUMBER;
v_org_id NUMBER;
v_cntr NUMBER;
v_file_name fnd_concurrent_requests.outfile_name%TYPE;
v_language VARCHAR2 (20);
BEGIN
SELECT fnd_profile.VALUE ('ORG_ID')
INTO v_org_id
FROM DUAL;
fnd_file.put_line (fnd_file.LOG, 'org id ' || v_org_id);
fnd_file.put_line (fnd_file.output, 'Start org id ' || v_org_id);
FOR i IN 1 .. 10000
LOOP
v_cntr := v_cntr + 1;
END LOOP;
l_ret :=
fnd_request.add_layout ('SQLAP',
' WMMGDSEPAFORMATXSL',
'en',
'US',
'XML'
IF l_ret = TRUE
THEN
BEGIN
fnd_file.put_line (fnd_file.output,
'Payment batch ' || p_payment_batch
l_req_id :=
fnd_request.submit_request ('SQLAP',
'WMMGDSEPAFORMAT',
FALSE,
p_payment_batch
v_cntr := 0;
FOR i IN 1 .. 10000
LOOP
v_cntr := v_cntr + 1;
END LOOP;
p_return_msg := 'Request submitted. ID = ' || l_req_id;
p_return_code := 0;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
p_return_msg :=
'Payment Request set submission failed - unknown error: '
|| SQLERRM;
p_return_code := 2;
fnd_file.put_line (fnd_file.LOG,
'the_request_id ' || l_req_id || p_return_msg
END;
END IF;
END wmmgd_sepa_formats;
Thanks in advanceAnd metalink note 1100253.1 states that this issue (java.lang.StackOverflowError) might be caused by a too large set of data to be sorted in the layout file. Recommendation is to removed the sort from the layout file and instead sort the data already in the data definition.
regards,
David. -
hi,
How can i find the sid of a submitted job? I can see the job running in dba_scheduler_jobs view but can't figure out on how to relate in v$session. Also, I would like to know the OS process id of this particular job.
appreciate any input.
Thanks,gonzroman wrote:
Thanks for the reply. I have a follow-up question. The submitted job creates another job which really does the work. It's somewhat there's a parent job and child created and would like to find the session of the child job.
I can see the parent which is great but would like to see what the child job is doing.
Thanks.Well,
You should go with DBMS_APPLICATION_INFO package: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_appinf.htm#CHECEIEB
Your child job will call something: lets say procedure which is called MYPROC1. That procedure will look like something like below:
create or replace procedure myproc1
as
begin
DBMS_APPLICATION_INFO.SET_MODULE( module_name => 'myproc1', action_name => 'myproc1 is called by child job');
--- procedure code ....
DBMS_APPLICATION_INFO.SET_MODULE( module_name => ' ', action_name => ' ');
end;What will happen here: When your child job starts execution, corresponding record in V$SESSION can be identified filtering on ACTION field.:
select * from v$session where action like '%myproc1 is called by child job%'As an alternative method, you can use: DBMS_APPLICATION_INFO.SET_CLIENT_INFO('I am child job which is created by parent job') then filter CLIENT_INFO field in $SESSION;
Hope you catch my idea.
Teymur Hajiyev
Oracle 10g Certified Master
http://teymur-hajiyev.blogspot.com
http://dba.az -
How Can I Run a SQL Loader Job from Schedular
How Can I Run a SQL Loader Job from Schedular , So that It Runs every Day.
Depends on a couple of factors.
If you are on a UNIX platform, you can create a shell script and schedule it with cron.
If you are on a Windows platform, you can create a batch file and schedule it with the Windows scheduler.
Or, if you are on Oracle 9i or 10g, you could use the external table feature instead of SQL*Loader. Then you could write a stored procedure to process the external table and schedule it using the Oracle scheduler (DBMS_JOB). This would probably be my preference. -
How to change sheduled jobs from one users to other user?
Hi,
I want to change shoulded jobs from one users to other user.
Is there any way that we change job from one user to other user.
apart procedure with sm37: single job selecting with copy option.
Regards,
Gianluca VincoHi,
Please try the folloiwng for changing the User of a Scheduled job:
1. Go to transaction SM37, select the 'Scheduled' Job by checking the check box and then use the menu path Job -
> Change
2. You may reach the Change Job xxx screen. Here, click on the Step button
3. You may reach the Step List Overview screen
4. Here select the step in the list and click on the Change icon to make the User change in the pop up Edit Step window
I hope this helps you in your work.
Best Regards
Sitaraman -
Executing OS command from sql procedure
i want to execute an OS command from the procedure, can i do this way? looks like it is not executing the command move....
declare
begin
dbms_output.put_line(' moving...');
host;
move c:\file1\test.txt C:\moved
exit;
/True. But that job is going to run in a separate session, some time after the current transaction commits (depending on the number of jobs queued up to run). So if you need to pass information back from the job, or you want the procedure to handle exceptions thrown by the job, or you want to tie job related failures back to a particular application level event, or you want the rest of your procedure to wait for the operating system command to finish, using the DBMS_SCHEDULER for this sort of thing is going to require a fair amount of additional coordination/ monitoring/ infrastructure code. It's certainly not a Herculean task to write that additional code, and it's reasonable in some situations, but the Java stored procedure approach strikes me as substantially easier to deal with in most cases.
Justin -
Calling shell script from sql procedure
Hi gurus
Is it possible
1)to call a shell script from sql procedure
2)that shell script has to return one value
3)and again sql procedure(calling shell script) has to capture the return value.
please help me to write this scriptYou may NOT have EXECUTE privilege/ permissions on the DBMS_PIPE package. Check with your DBA.
Using DBMS_PIPE may not be that simple to implement. Just making a call to DBMS_PIPE procedure will not do anything. It will NOT trigger anything on the UNIX side.
. You will also need to :
1. Write a job (ie CRON) at UNIX side which will keep read the incoming pipe for new messages, Unpack the message and get the command to be executed at the UNIX side -- There will be a lot of work involved here + DBA presence/activity is also required.
As Justin has pointed out, try and use HOST command which is very simple or try and use Java.
Shailender Mehta -
Can I execute a scenario from a procedure?
Can I execute a scenario from a procedure? I know I can execute scenarios from the command line. I was hoping to avoid that since I need my job to run in multiple envirnoments and may not reliably know where STARTSCEN is located or if it will always work. Basically, I would like to execute several jobs multiple times, depending on values in a table that will be changed between runs.
Hi,
Yes you can exetute an ODI scenario from an ODI procedure.
Technology for that procedure will be Sunopsis API
code OdiStartScen "-SCEN_NAME=<scenario name>" " -SCEN_VERSION=<scenario version>" "-CONTEXT=<context code name>"
Thanks,
Sutirtha -
System command execution from stored procedure
Hello World,
How to run System command from stored procedure ?
For example :
Delete a file
running a programm,
Is it possible ?
H.MYears ago I did this by writing an output file with commands into a directory and had a cron job looking for this file. At the end of the run the file was removed.
Never checked if there are other possibilities nowadays.
cu
Andreas
Maybe you are looking for
-
How to open xls files in Mountain Lion
I upgraded to Mountain Lion and now cannot open xls files. xlsx files open fine. Is there a way to convert the xls files?
-
I Told The Bus Driver She Aint Call The Police. She Said Who Ever Got Gave It Up . Or When She Find Out Who Got My Ipod They Getting Expel....I Got Home Told My Mother She Took Me To The Police Satiton And They Didnt Do NOthing About It. But Say You
-
New Tiger 10.4.6 installation Questions
Just installed a new retail version of Tiger 10.4.6 today. I bought it from Apple. It's up and running and I'm using it now, but I have some questions and things I'm not sure about. When I bought the DVD the Apple rep told me it was not compatible wi
-
How can I specify which divs to display using js/css
I'm building a web app that will be converted to a smartphone app, probably using phone gap build. I began by using the jquery mobile sample which appears to work well. The app will display a series of phrases on the page in English and then optional
-
I'm working with another designer that keeps updating graphics that I've linked within my InDesign CS3 document. He's working in AI CS3. When he updates a file I cannot find an easier way than opening and closing my entire document to update the link