Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: DBMS-JOBS - ids
On Tue, 27 Jan 1998 21:25:51 +0000, Jonathan Waland <jonathan.waland_at_vf.vodafone.co.uk> wrote:
>Is it possible for a dbms_job to find out it's own job id?
>
>I want to be able to submit n-jobs, and when a job runs it
>would be aware of it's job id (for logging purposes for example)
>
>thanks in advance,
>
>Jon
If you pass the job id into the job when you queue it, you'll get what you need (make the job id part of the inputs to the job). One way (the 'bad' way) would be to use isubmit and assign the job number -- the presupposes you know a free job id. I prefer to let the system assign the job number itself. If you do that, the following example shows you how to queue a job that knows what id it is....
create table msg ( x varchar2(2000) );
create or replace procedure some_job( my_id in number default null )
as
begin
insert into MSG values ( 'My job id is: ' || my_id );
end;
/
set serveroutput on
declare
l_job number;
begin
dbms_job.submit( l_job, 'some_job;' ); dbms_job.change( job => l_job,
what => 'some_job( ' || l_job || ');', next_date => NULL, -- don't change interval => NULL ); -- don't changedbms_output.put_line( 'Job ' || l_job || ' submitted...' ); commit;
See, we queue the job but don't pass in the job id (we don't know what it is at first). Once we get it, we 'change' the job so it now knows its job id, we pass nulls for the other two things about a job we could change but don't want to.
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Tue Jan 27 1998 - 00:00:00 CST