# Bug in SB DBMS\_JOB Generated Script

**URL:** <https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065>\
**Category:** Toad for Oracle & DevOps Toolkit\
**Created:** [September 15, 2022, 6:07pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065 "2022-09-15T18:07:47Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![russell.cannon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/russell.cannon/32/12042_2.png) [@russell.cannon](https://forums.toadworld.com/u/russell.cannon)\
**Post date:** [September 15, 2022, 6:07pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/1 "2022-09-15T18:07:47Z")

</div>

There is a very old forum thread on this, but I decided to open a new one instead to bring it to your attention. Take a look at the following image from TOAD 16.0:

 ![TOAD generated job remove code](https://global.discourse-cdn.com/quest/original/2X/1/15ae22c11fbf52496544ee830b4393d4f235b49d.png)

With 'Script Options-\>Drop Statement' checked, the call in the remove block for the selected job is to DBMS\_IJOB though the calls in the create block are to DBMS\_JOB. The remove is calling the, as of 19c, non-existent DBMS\_IJOB even though I am logged in as the owner of the job.

Cheers,  
Russ

---

<div class="post-metadata">

**Author:** ![Gary.Jerep](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/gary.jerep/32/205_2.png) [@Gary.Jerep](https://forums.toadworld.com/u/Gary.Jerep)\
**Post date:** [September 15, 2022, 6:40pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/2 "2022-09-15T18:40:35Z")

</div>

Appears to be a discrepancy there, and thanks for bringing it to our attention... Dev will need to take a closer look...

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [September 15, 2022, 7:16pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/3 "2022-09-15T19:16:30Z")

</div>

DBMS\_IJOB still exists on my 19c database, we shouldn't have any references to it if it doesn't exist. I do, however, see a way that the check to make sure it exists and you have privs on it could get bypassed.

If you go in here and uncheck "Schema Name", you should see DBMS\_JOB instead.  
Also, look on the "Jobs" tab in that dialog and make sure that the dbms\_ijob option is unchecked.

 ![image](https://global.discourse-cdn.com/quest/original/2X/5/5c3275bf31e54e5303d8b798dd77d03d897162b3.png)

---

<div class="post-metadata">

**Author:** ![russell.cannon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/russell.cannon/32/12042_2.png) [@russell.cannon](https://forums.toadworld.com/u/russell.cannon)\
**Post date:** [September 15, 2022, 7:20pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/4 "2022-09-15T19:20:21Z")

</div>

Yep. That works. It's just that I need Schema Name.

---

<div class="post-metadata">

**Author:** ![russell.cannon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/russell.cannon/32/12042_2.png) [@russell.cannon](https://forums.toadworld.com/u/russell.cannon)\
**Post date:** [September 15, 2022, 7:21pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/5 "2022-09-15T19:21:22Z")

</div>

When I am actually logged in as the owner, I should not get DBMS\_IJOB at all or the set current\_schema calls.

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [September 15, 2022, 7:25pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/6 "2022-09-15T19:25:00Z")

</div>

The use of DBMS\_IJOB w/o having privs is a bug and I'll fix it.

Why do you need Schema Name here? Or is it just that you don't want to uncheck it for Jobs, then have to recheck it when you go back to some other object type?

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [September 15, 2022, 7:33pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/7 "2022-09-15T19:33:52Z")

</div>

Here is the reason that the SET CURRENT SCHEMA calls are there even when you are logged in as the job owner:

Think of having the "schema name" box checked on the tables tab. There (and for all other object types), the schema name will be included, even if you are logged in as the table owner. This way, when the script is run later, no matter who you are logged in as, the table will be created under the schema from which it was extracted.

The only way to achieve that with jobs is with the SET CURRENT SCHEMA command, or to use DBMS\_IJOB.

---

<div class="post-metadata">

**Author:** ![russell.cannon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/russell.cannon/32/12042_2.png) [@russell.cannon](https://forums.toadworld.com/u/russell.cannon)\
**Post date:** [September 15, 2022, 7:33pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/8 "2022-09-15T19:33:52Z")

</div>

Yep. We have dozens of schemas and thousands of objects of various kinds. We need schema name references everywhere, and if we have to keep switching this setting, there will inevitably be mistakes that will find their way into our code repository. Like, "Oh, I forgot to set that schema setting back after dorking with that other stuff." Not good. We need to be able to have that setting checked all the time.

Also, I have a bone to pick about the Jobs tab of Script Options. It needs a 'Use ISUBMIT to preserve job number' option. (DBMS\_IJOB no longer exists as of 19c, but DBMS\_JOB.ISUBMIT does.) As it is, we have to manually edit the script the tool offers so that we can set our job numbers so that they will be the same across many databases. This is something that has chafed me about TOAD for a long time.

Cheers,  
Russ

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [September 15, 2022, 7:37pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/9 "2022-09-15T19:37:55Z")

</div>

DBMS\_IJOB still exists on 19c. See below. I'll test the job number option.

![image](https://global.discourse-cdn.com/quest/original/2X/0/014d2d2a94f7032d11eebb8c43288d8d83f868e2.png)

---

<div class="post-metadata">

**Author:** ![russell.cannon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/russell.cannon/32/12042_2.png) [@russell.cannon](https://forums.toadworld.com/u/russell.cannon)\
**Post date:** [September 15, 2022, 7:40pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/10 "2022-09-15T19:40:09Z")

</div>

Yep you are right. I just needed to take off my filters and be DBA.

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [September 15, 2022, 8:16pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/11 "2022-09-15T20:16:28Z")

</div>

I just tested the "preserve job number" option. I got a script like this, and when I ran it, the job number was the same for the new job. Of course, if you are logged in as a user that does not have access to dbms\_ijob, this isn't going to work.

I see what you mean about DBMS\_JOB.ISUBMIT though. I'll log an enhancement request to use that when DBMS\_IJOB is not available.

```auto
BEGIN 
  SYS.DBMS_IJOB.REMOVE(20883);
  COMMIT;
END;
/

DECLARE
  NewJobID NUMBER;
BEGIN
  NewJobID := 20883;
  SYS.DBMS_IJOB.SUBMIT
    ( job => NewJobID 
     ,luser => 'JDORLON'
     ,puser => 'JDORLON'
     ,cuser => 'JDORLON'
     ,what => 'begin null; end;'
     ,next_date => TO_DATE('2022-10-15', 'YYYY-MM-DD')
     ,interval => 'TRUNC(SYSDATE+30)'
     ,broken => FALSE
     ,nlsenv => 'NLS_LANGUAGE=''AMERICAN'' NLS_TERRITORY=''AMERICA'' NLS_CURRENCY=''$'' NLS_ISO_CURRENCY=''AMERICA'' NLS_NUMERIC_CHARACTERS=''.,'' NLS_CALENDAR=''GREGORIAN'' NLS_DATE_FORMAT=''DD-MON-RR'' NLS_DATE_LANGUAGE=''AMERICAN'' NLS_SORT=''BINARY'' NLS_TIME_FORMAT=''HH.MI.SSXFF AM'' NLS_TIMESTAMP_FORMAT=''DD-MON-RR HH.MI.SSXFF AM'' NLS_TIME_TZ_FORMAT=''HH.MI.SSXFF AM TZR'' NLS_TIMESTAMP_TZ_FORMAT=''DD-MON-RR HH.MI.SSXFF AM TZR'' NLS_DUAL_CURRENCY=''$'' NLS_COMP=''BINARY'' NLS_LENGTH_SEMANTICS=''BYTE'' NLS_NCHAR_CONV_EXCP=''FALSE'''
     ,env => '0102000000000000');
  SYS.DBMS_OUTPUT.PUT_LINE
    ('Job Number is: ' || to_char(NewJobID));
  COMMIT;
END;
/

```

---

<div class="post-metadata">

**Author:** ![russell.cannon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/russell.cannon/32/12042_2.png) [@russell.cannon](https://forums.toadworld.com/u/russell.cannon)\
**Post date:** [September 15, 2022, 9:20pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/12 "2022-09-15T21:20:56Z")

</div>

The job parameter of DBMS\_IJOB.SUBMIT is an IN/OUT while in DBMS\_JOB.SUBMIT it is an OUT. With DBMS\_JOB.ISUBMIT, it is an IN/OUT. Also, DBMS\_IJOB and DBMS\_JOB.ISUBMIT have two different purposes. The former, being undocumented, was clearly intended to be used internally--perhaps by Data Pump--to be able to build DBMS\_JOBs in any schema. The latter, is solely meant for specifying the job number instead of just taking a generated one all other things being the same.

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [September 15, 2022, 9:59pm UTC](https://forums.toadworld.com/t/bug-in-sb-dbms-job-generated-script/56065/13 "2022-09-15T21:59:08Z")

</div>

Hi Russ,

I agree with all of that.

That the dbms\_ijob.submit code has been in Toad for, I would guess, 15-20 years (or more). I vaguely remember adding it at user request, I think as a way to create a job for in a different schema. I think the "preserve the job number" idea came later, and when it did, I may have just seen that could be done in dbms\_ijob w/o looking for a way in dbms\_job. Not sure.

Anyway, I've logged an ER to preserve the job number with dbms\_job.isubmit. I'll add that in the next version (17.0). We're wrapping up 16.2 now.

-John
