DBMS_JOB Failed

Hi,
We have this job which has been running all while and it suddently failed this time.Here are some infor I got from the .trc file.How can I get this fix.
Oracle9i Release 9.2.0.7.0 - 64bit Production
JServer Release 9.2.0.7.0 - Production
ORACLE_HOME = /oracle/product/9.2.0.7
System name: HP-UX
Node name: oxibux01
Release: B.11.11
Version: U
Machine: 9000/800
Instance name: oxiprd
Redo thread mounted by this instance: 1
Oracle process number: 34
Unix process pid: 26101, image: oracle@oxibux01 (J001)
*** SESSION ID:(36.55547) 2009-05-30 04:04:03.095
*** 2009-05-30 04:04:03.095
ORA-12012: error on auto execute of job 43
ORA-08103: object no longer exists
ORA-06512: at "SYS.DBMS_STATS", line 10301
ORA-06512: at "SYS.DBMS_STATS", line 10795
ORA-06512: at "SYS.DBMS_STATS", line 10982
ORA-06512: at "SYS.DBMS_STATS", line 11036
ORA-06512: at "SYS.DBMS_STATS", line 11013
ORA-06512: at "MMSDBA.ANALYZE_DATABASE", line 4
ORA-06512: at line 1

ORA-08103: object no longer existsCould you please paste the source of your Job and verify its status from DBA_SCHEDULER_JOB_LOG by setting logging_level of job to LOGGING_FULL
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

Similar Messages

  • DBMS_JOBS fails inside a DDL trigger when granting permissions to roles

    Hi,
    I have a DDL Trigger through which I am granting SELECT on newly created tables to existing read-only roles
    CREATE OR REPLACE TRIGGER DBADMIN.grant_permission_trigger
    AFTER CREATE
    ON DATABASE
    DECLARE
    v_owner dba_tables.owner%TYPE;
    v_role dba_roles.role%TYPE;
    v_object dba_tables.table_name%TYPE;
    v_object_type dba_objects.object_type%TYPE;
    n_temp_int INTEGER DEFAULT 0 ;
    l_job NUMBER;
    n_temp dba_tables.temporary%TYPE;
    BEGIN
    --selecting owner
    SELECT ora_dict_obj_owner INTO v_owner FROM DUAL;
    v_role := v_owner || '_S';
    --selecting table name
    SELECT ora_dict_obj_name INTO v_object FROM DUAL;
    SELECT ORA_DICT_OBJ_TYPE INTO v_object_type FROM DUAL;
    IF (v_object_type = 'TABLE')
    THEN
    SELECT COUNT (1)
    INTO n_temp_int
    FROM dba_roles
    WHERE role = v_role;
    -- if a role does not exist already, then create a role
    IF n_temp_int != 0
    THEN
    SELECT temporary
    INTO n_temp
    FROM dba_tables
    WHERE table_name = v_object;
    IF (n_temp = 'N')
    THEN
    DBMS_JOB.submit (
    job => l_job,
    what => 'BEGIN EXECUTE IMMEDIATE ''GRANT SELECT ON '
    || v_owner
    || '.'
    || v_object
    || ' TO '
    || v_role
    || '''; END;'
    END IF;
    END IF;
    END IF;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    END;
    I am executing this trigger as DBADMIN having the following explicit grants
    grant any object privilege
    SELECT ANY DICTIONARY
    The problem happens when someone creates a table in their procedure and drops it off at the end of the procedure, the JOB which is in the queue when it executes, it cannot find the table and the jobs are failing.
    I have given a check to see if its temporary. But still the jobs are failing. I am missing someting
    Can someone let me know what should be done? I have production issues which should be resolved.

    Hi,
    The problem happens when someone creates a table in their procedure and drops it off at the end of the procedure, the JOB which is in the queue when it executes, it cannot find the table and the jobs are failing.Seems more like this is the problem:
    SELECT temporary
    INTO n_temp
    FROM dba_tables
    WHERE table_name = v_object;If that would not throw NO_DATA_FOUND, there would be no need for the dbms_job.
    Seems safe to remove, you are not using n_temp and if it raises no_data_found you are doing nothing.
    Also, these are not necessary
    SELECT ora_dict_obj_owner INTO v_owner FROM DUAL;
    SELECT ora_dict_obj_name INTO v_object FROM DUAL;
    SELECT ORA_DICT_OBJ_TYPE INTO v_object_type FROM DUAL;You can use System Events in PL/SQL
    Why this comment?
    -- if a role does not exist already, then create a roleYou aren't trying to create a role.
    Regards
    Peter

  • Technical note:  Troubleshooting DRG-11207 errors / INSO filters.

    All,
    The following is Metalink's Note 210319.1about troubleshooting DRG-11207 errors.
    If the content is of no help, I suggest contacting Oracle support.
    -Omar
    Subject: Troubleshooting DRG-11207 errors
    INTRODUCTION
    =============
    Most of the errors encountered during creation of Oracle Text indexes are likely
    to be caused when dealing with formatted documents. These errors are logged in the
    view CTX_USER_INDEX_ERRORS and can be queried from the schema where the create index
    statement was executed, or table CTX_INDEX_ERRORS queried from the CTXSYS user.
    One of the errors commonly reported in these views is the DRG-11207 error.
    Unfortunately, this error is often not useful in diagnosing indexing issues.
    The INSO_FILTER issues are difficult to diagnose because Oracle uses a third-party
    application for filtering. As a result, it is often difficult to identify the real
    source of the problem.
    This document will troubleshoot the INSO_FILTER errors associated with
    the
    DRG-11207 "exited with status X"
    message. In regards to the INSO_FILTER, the error code implies that it is unable to
    index a formatted document. It is important to mention that these errors can be operating
    system specific and therefore this note is intended to provide some hints as a starting
    point for analysis. Its possible that other cases may be reported and if this is the
    case be sure to log the error with Oracle Support. Examples of the most common document
    types are provided in this article (Adobe PDF, Micrsoft Word and Microsoft Excel).
    For Oracle 10i, meaningful error messages have been added for drg-11207.
    This has been documented in [BUG:2473885]
    COMMON ERRORS
    ==============
    DRG-11207: user filter command exited with status 1
    Status 1 means "Could not filter the document". It is a generic error and indicates that
    INSO_FILTER failed on a given document. This can happen due to many documented reasons: an
    invalid environmental setting; document is corrupted, encrypted, password protected;
    document version not supported(incompatibility) or due to a bug in INSO_FILTER.
    DRG-11207: user filter command exited with status 2
    Status 2 means "The INSO_FILTER has timed-out". The default value of the timeout value
    for the INSO_FILTER is 120 (seconds). The default value for the timeout_type is
    heuristic, which implies that if the timeout value is reached and the INSO_FILTER
    has not started to write output, the indexing operation terminates for the document
    row and Oracle moves to the next document row to be indexed. Beginning in 9.2.0.1
    it is possible to change the timeout_type variable to fixed, which allows a
    user to terminate filtering processing after the TIMEOUT seconds regardless of
    whether filtering is progressing normally or hanging. The default timeout value
    is generally enough for filtering most of the documents. If the timeout value is
    not large enough then it may timeout even before filtering completes. PDF and
    Microsoft Excel files are usually more prone to this timeout as the INSO_FILTER
    generally takes more time to process these types of files. If this is the
    case then you can create a preference with a larger timeout value in versions
    8.1.7.1b and above. It should be noted, however, that the timeout attribute cannot be
    changed dynamically. In order for the new timeout value to take effect, it
    would be necessary to re-create the index with the new timeout attribute
    setting.
    For example, in 9.2.x to alter the timeout to 600 seconds(10 minutes) and use
    the fixed timeout_type:
    begin
    ctx_ddl.create_preference('my_inso', 'INSO_FILTER');
    ctx_ddl.set_attribute('my_inso', 'timeout', '600');
    ctx_ddl.set_attribute('my_inso', 'timeout_type', 'FIXED');
    end;
    Documented reasons for timing out are:
    1. the document is too large to be indexed in the alloted time set via TIMEOUT
    attribute.
    2. INSO_FILTER is hanging during the filtering.
    DRG-11207: user filter command exited with status 127
    Status 127 points to that likely an environmental issue with the shared library
    environmental variable.
    DRG-11207: user filter command exited with status 137
    Status 137 meand that the ctxhx executable was killed as the inso filter is not
    set-up properly. Confirm that the correct environmental variables are
    setup(LD_LIBRARY_PATH AND PATH) and the format of the document is
    supported by INSO_FILTER.
    ENVIRONMENTAL SETTINGS
    ======================
    Please note that any DRG-11207 error may be caused by the setting of the
    environmental variables. Be sure that the PATH and shared library path
    which is LD_LIBRARY_PATH (SHLIB_PATH for HP-UX and LIBPATH for AIX) are
    correct, since it is this setting which actually invokes the INSO_FILTER.
    Note : it is also possible to define the environment variable
    LD_LIBRARY_PATH in the listener.ora entry for extproc. This would be
    included in the ENVS section of the origin database LISTENER.ORA:
    ENVS = 'LD_LIBRARY_PATH=<full_pathname_of_oracle_home>/ctx/lib:$ORACLE_HOME/lib'
    LD_LIBRARY_PATH should include
    <full_pathname_of_oracle_home>/ctx/lib:<full_pathname_of_oracle_home>/lib
    For example:
    export LD_LIBRARY_PATH=<full_pathname_of_oracle_home>/ctx/lib:$LD_LIBRARY_PATH
    PATH should include
    <full_pathname_of_oracle_home>/ctx/bin:<full_pathname_of_oracle_home>/bin
    [NOTE:133691.1] and [NOTE:135333.1] provides possible steps to get around this error.
    SUPPORTED DOCUMENT ATTRIBUTE CHECKLIST
    ======================================
    1. Determine if the filtered document is supported
    A list of supported formats is provided in the InterMedia Text documentation
    pages. Please check whether the format falls in the list of supported formats.
    It is important to note that each Oracle version may support different
    versions of documents.
    For PDF Acrobat (full version), click on File->Document_Info->General and
    you should see the PDF version.
    For Microsoft Word and Excel, click on File->Save As and review the
    "Save as type" to determine the version.
    2. Determine if the document is corrupted
    To verify if a document is corrupted, open the document and view it line
    by line checking for corrupted output. Please note, just holding down the
    "Page Down" button to view all the pages, it's possible that potential
    corruption on a particular page will go unnoticed.
    3. Determine if the document is a secure or copy protected document
    Password protected documents and documents with password protected contents
    are not supported by the INSO_FILTER.
    For PDF Acrobat (full version), click under file->document_info->security.
    If the open password or security password is set to true then it's password
    protected.
    For Microsoft Word, click under Tools->Options->Save. If the
    "Password to open" or "Password to modify" appears as asterisks (*****),
    then the document is secured.
    For Microsoft Excel, click under File->Save As->Tools->General options.
    If the "Password to open" or "Password to modify" appears as
    asterisks (*****), then the document is secured.
    4. Determine if the document is a encrypted
    INSO_FILTER does not currently support encrypted documents.
    For PDF Acrobat (full version), click under file->document_info->security.
    If security method is none, the document is not encrypted. In other cases,
    it is encrypted.
    For Microsoft Word, it is not possible to encrypt this type of document
    directly.
    For Microsoft Excel, if the document is workbook protected then this
    implies that the document is encrypted. To determine this click under
    tools->protection and if the Unprotect Workbook or Unprotect
    Sheet is shown, this implies that the workbook/worksheet is encrypted.
    5. Determine if the document has custom embedded fonts
    Stellent filters will succeed on the majority of PDF documents containing
    custom fonts. Until now, there have only been a few documented cases of
    custom embedded fonts causing filtering problems with PDF documents. If
    there is a filtering problem with custom fonts, it will only result in
    garbage tokens being produced as a result of the custom font, whereas the
    remainder of the PDF document using the standard/built-in font will be
    filtered properly.
    To determine if custom embedded fonts are used for PDF Acrobat (full version),
    click under file->document_info->fonts and review the encoding type.
    The best way to identify whether a particular custom font will filter successfully
    is to highlight the character, copy and paste into Notepad. If the output
    contains garbage text then it is not likely to be filtered properly.
    For Microsoft Word and Excel, regardless of what font is being used, the
    INSO_FILTER should be able to extract the characters.
    References
    Oracle Text Reference Releases 9.1 and 9.2
    [BUG:2473885] BETTER ERROR MESSAGES FOR WHEN CREATING INTERMEDIA INDEX
    USING INSO FILTER
    [NOTE:133691.1] Create context index fails with DRG-11207 or fatal:libsc_fa.so
    [NOTE:135333.1] CTX_DDL.SYNC_INDEX With DBMS_JOB Fails (DRG-11207) Using
    INSO Filter in V817
    [BUG:1795642] INTERMEDIA TEXT INDEX OF A CERTAIN EXCEL97 FILE IS NOT
    CREATED IN WEBDB SITE

    Gary,
    This is two questions:
    1. The INSO filter on 8.1.7 when converting MS Word or WordPrefect Docs to HTML would give you <I> and <B> used in
    the word processor. The 9.2.0.1 version is not converting <I> or <B> in the HTML. Is there any documentation
    from the Company on using the ctxhx and template files? If <I> and <B> tags are missing in 9.2.0.1 then it is a bug in the INSO code.
    2. I have received an error in the CTX_USER_INDEX_ERRORS from one of the docs store in a BLOB here is the error.
    DRG-11207: user filter command exited with status 1.
    Is there a way to debug the ctxhx or INSO load libraries? I know what a 137 error is (NO LD_LIBRARY_PATH for ctx/lib)
    but what a 1. Where is the FL_CMD_EXIT_ERR info? Status 1 is a generic error and you can't debug it. Could you please post your email address? I would like to contact you for a test case.
    Thanks.

  • Dbms_job.submit failed

    Hi all,
    I'm just wondering why is it that when i submit a job using dbms_job.submit, it always fails.. But when I try dbms_job.run or execute the procedure itself, the procedure was executed successfully and I was able to get the output that i want.
    Here's my code snippet:
    declare
    x_job number;
    begin
    sys.dbms_job.submit(x_job, 'begin cl_msg2.cl_msg_call; end;', sysdate,NULL);
    commit;
    end;
    I tried to check the alert_log.txt and it shows this error:
    Errors in file /u1/oracle/admin/ABC4/bdump/snp3_1854.trc:
    ORA-12012: error on auto execute of job 694
    ORA-20001:
    ORA-06512: at "ABCDEV.SYSTOR", line 81
    ORA-06512: at "ABCDEV.CL_MSG2", line 512
    ORA-06512: at "ABCDEV.CL_MSG2", line 21
    ORA-06512: at line 1
    When i check for the source of the error, I found out that the sqlcode it returns is 100.. which means no_data_found. It's doing an update on a table. (I've tried running the )
    It's kinda weird because when I checked the record on the table, it DOES exists.. And as I've mentioned earlier, there's no problem when i use dbms_job.run to run the procedure.
    I really don't have an idea as to what have caused the failure on the job.
    Thanks and regards,
    Anna

    Hi,
    Thanks for the immediate reply. Sorry, but I have a very little knowledge when it comes to database issues.. And this is my first time to use dbms_job utility. Here is the code snippet of where the error occurs:
    BEGIN
    UPDATE CL_DRAWDOWN SET msg_cnf = 'Y'
    WHERE dd_key = cmsg.dd_key
    AND loan_no = cmsg.loan_no
    AND dd_no = cmsg.dd_no;
    EXCEPTION
    WHEN OTHERS THEN
    Systor.insert_error_msg (SQLCODE, 'CL_MSG2', 'MSG_PAY', 'O', '10 '|| TO_CHAR(cmsg.dd_key));
    END;
    As you can see on the above snippet, SYSTOR package is being used to handle exception and for monitoring/recording of errors. It actually inserts the error encountered on a table and raise an application error with code -20001.
    Im not really sure I understand this part
    'Ordinary session and job session have different environment. Your code can (recursively) query v$session in unappropriate way.'. Could you please elaborate?
    Thanks a lot for your help!

  • Dbms_job - running update on another schema is failing

    Hi all,
    I believe I've traced my problem down to a permissions issue, but I'm not exactly sure why.
    I have three users in a particular database. One user has DBA access, one user is there just to be the owner of everything and a third user which will be the account our web app uses to connect so we can assign privliges appropriately.
    I'm signed in as the DBA account (not SYS) and I can run a simple update statement on a table in the main schema:
    insert into mainuser.bloodtype (blood_type) values('z');
    Do a commit, and it's all good. Now I try putting that same SQL into a job:
    DECLARE
    jn binary_integer;
    begin
         DBMS_JOB.SUBMIT(jn, 'insert into mainuser.bloodtype (blood_type) values(''z'');',SYSDATE + 1/1440);
         DBMS_OUTPUT.PUT_LINE(jn);
         commit;
    END;
    When I check all_jobs, the job is there with the SQL listed exactly as it should be executed however the job ends up failing. Now I tried something similar but working strictly inside the DBA's schema and it works fine. So there must be something I'm missing due to permissions...but since the SQL works outside the job I'm not sure what it is. Is there a view or log I could look at in order to determine what the cause of the failure is, or does anyone know exactly why this is failing?
    The ultimate goal here is to grant the webuser account enough privliges to submit jobs in order to execute SQL to update items in the database based on a scheduled time. I'm just testing right now using the DBA account as I thought this would be easy to get working.
    Thanks.

    .......wouldn't you know it worked now.?!
    I'm not sure I understand the 'why' behind that though....it sort of makes roles a bit useless, no?No.
    [url http://asktom.oracle.com/pls/ask/f?p=4950:1:11743829664184798667:pg_R_576301530530070&pg_min_row=11&pg_max_rows=10&pg_rows_fetched=10]AskTom

  • Procedure successful when using dbms_job, but fails in a shell script

    I have a procedure which is throwing the following error when run from a shell script. This procedure completes successfully when run using dbms_job
    ORA-00164 distributed autonomous transaction disallowed within migratable distributed transaction

    Mohan et al,
    When I get an ORA error that I don't understand I plug it into Google; use the whole error code, ie 'ORA-00164'.
    The second link in this case gives a reasonable explanation of what is happening.
    http://www.dbasupport.com/oracle/ora9i/autonomoustrans.shtml
    Cheers,
    Colin

  • Script fails when passing values from pl/sql to unix variable

    Script fails when passing values from pl/sql to unix variable
    Dear All,
    I am Automating STATSPACK reporting by modifying the sprepins.sql script.
    Using DBMS_JOB I take the snap of the database and at the end of the day the cron job creates the statspack report and emails it to me.
    I am storing the snapshot ids in the database and when running the report picking up the recent ids(begin snap and end snap).
    From the sprepins.sql script
    variable bid number;
    variable eid number;
    begin
    select begin_snap into :bid from db_snap;
    select end_snap into :eid from db_snap;
    end;
    This fails with the following error:
    DB Name DB Id Instance Inst Num Release Cluster Host
    RDMDEVL 3576140228 RDMDEVL 1 9.2.0.4.0 NO ibm-rdm
    :ela := ;
    ERROR at line 4:
    ORA-06550: line 4, column 17:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    ( - + case mod new not null &lt;an identifier&gt;
    &lt;a double-quoted delimited-identifier&gt; &lt;a bind variable&gt; avg
    count current exists max min prior sql stddev sum variance
    execute forall merge time timestamp interval date
    &lt;a string literal with character set specification&gt;
    &lt;a number&gt; &lt;a single-quoted SQL string&gt; pipe
    The symbol "null" was substituted for ";" to continue.
    ORA-06550: line 6, column 16:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    ( - + case mod new not null &lt;an identifier&gt;
    &lt;a double-quoted delimited-identifier&gt; &lt;a bind variable&gt; avg
    count current exists max min prior sql stddev su
    But when I change the select statements below the report runs successfully.
    variable bid number;
    variable eid number;
    begin
    select '46' into :bid from db_snap;
    select '47' into :eid from db_snap;
    end;
    Even changing the select statements to:
    select TO_CHAR(begin_snap) into :bid from db_snap;
    select TO_CHAR(end_snap) into :eid from db_snap;
    Does not help.
    Please Help.
    TIA,
    Nischal

    Hi,
    could it be the begin_ and end_ Colums of your query?
    Seems SQL*PLUS hs parsing problems?
    try to fetch another column from that table
    and see if the error raises again.
    Karl

  • Start one job after another complets using PL/SQL procedure and DBMS_JOB

    All,
    I am attempting to refresh a materialized view using DBMS_JOB and having a PL/SQL program loop through each materialized view name that resides in a table I created. We do the table because they have to be refreshed in a specific order and I utilize the ORDER_OF_REFRESH column to dictate which MV comes first, second, third, etc.
    Now - I have this working to the extent that it kicks off 4 materialized views (currently set the procedure to only do 4 MVs for testing purposes) but I would ultimately like the procedure to create a new DBMS_JOB that calls DBMS_MVIEW.REFRESH of the next view in line ONLY after the preceeding materialized view DBMS_JOB completes.
    The purpose of all of this is to do a few things. One - if I simply create a procedure with the DBMS_MVIEW.REFRESH call to each materialized view in order - that works but if one fails, the job starts over again and will up to 16 times - BIG PROBLEM. Secondly, we want the job that will call this procedure to fail if it encounters 2 failures on any one materialized view (because some MVs may be dependant upon that data and cannot use old stale data).
    This may not be the "best" approach but I am trying to make the job self-sufficient in that it knows when to fail or not, and doesn't kick off the materialized views jobs all at once (remember - they need to start one after the other - in order).
    As you can see near the bottom, my logic doesn't work quite right. It kicks off all four jobs at once with the date of the whatever LAST_REFRESH is in my cursor (which ultimately is from the prior day. What I would like to happen is this:
    1.) 1st MV kicks off as DBMS_JOB and completes
    2.) 2nd MV kicks off with a start time of 3 seconds after the completion of 1st MV (based off LAST_REFRESH) date.
    3.) This conitnues until all MVs are refresh or until 2 failures are encountered, in which no more jobs are scheduled.
    - Obviously I am having a little bit of trouble with #2 and #3 - any help is appreciated.
    CREATE OR REPLACE PROCEDURE Next_Job_Refresh_Test2 IS
    V_FAILURES NUMBER;
    V_JOB_NO NUMBER;
    V_START_DATE DATE := SYSDATE;
    V_NEXT_DATE DATE;
    V_NAME VARCHAR2(30);
    V_DELIMITER VARCHAR2(1);
    CURSOR MV_LIST IS SELECT DISTINCT A.ORDER_OF_REFRESH,
                                  A.MV_OBJECT_NAME
                        FROM CATEBS.DISCO_MV_REFRESH_ORDER A
                        WHERE A.ORDER_OF_REFRESH < 5
                   ORDER BY A.ORDER_OF_REFRESH ASC;
    CURSOR MV_ORDER IS SELECT B.ORDER_OF_REFRESH,
                                  B.MV_OBJECT_NAME,
                                  A.LAST_REFRESH
                             FROM USER_SNAPSHOTS A,
                                  DISCO_MV_REFRESH_ORDER B
                             WHERE A.NAME = B.MV_OBJECT_NAME
                        ORDER BY B.ORDER_OF_REFRESH ASC;
    BEGIN
    FOR I IN MV_LIST
    LOOP
    IF I.ORDER_OF_REFRESH = 1
    THEN V_START_DATE := SYSDATE + (30/86400); -- Start job one minute after execution time
              ELSE V_START_DATE := V_NEXT_DATE;
    END IF;
         V_FAILURES := 0;
         V_JOB_NO := 0;
         V_NAME := I.MV_OBJECT_NAME;
         V_DELIMITER := '''';
    DBMS_JOB.SUBMIT(V_JOB_NO,'DBMS_MVIEW.REFRESH(' || V_DELIMITER || V_NAME || V_DELIMITER || ');',V_START_DATE,NULL);
              SELECT JOB, FAILURES INTO V_JOB_NO, V_FAILURES
              FROM USER_JOBS
              WHERE WHAT LIKE '%' || V_NAME || '%'
              AND SCHEMA_USER = 'CATEBS';
    IF V_FAILURES = 3
    THEN DBMS_JOB.BROKEN(V_JOB_NO,TRUE,NULL); EXIT;
    END IF;
    FOR O IN MV_ORDER
    LOOP
    IF I.ORDER_OF_REFRESH > 2
    THEN V_NEXT_DATE:= (O.LAST_REFRESH + (3/86400)); -- Start next materialized view 3 seconds after completion of prior refresh
    END IF;
    END LOOP;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND
         THEN
              IF MV_LIST%ISOPEN
                   THEN CLOSE MV_LIST;
              END IF;
    NULL;
    END Next_Job_Refresh_Test2;
    ---------------------------------------------------------------------------------------------------------------------

    Justin,
    I think I am getting closer. I have a procedure shown just below this that updates my custom table with information from USER_SNAPSHOTS to reflect the time and status of the refresh completion:
    CREATE OR REPLACE PROCEDURE Upd_Disco_Mv_Refresh_Order_Tbl IS
    V_STATUS VARCHAR2(7);
    V_LAST_REFRESH DATE;
    V_MV_NAME VARCHAR2(30);
    CURSOR MV_LIST IS SELECT DISTINCT NAME, LAST_REFRESH, STATUS
                             FROM USER_SNAPSHOTS
                        WHERE OWNER = 'CATEBS';
    BEGIN
    FOR I IN MV_LIST
    LOOP
         V_STATUS := I.STATUS;
         V_LAST_REFRESH := I.LAST_REFRESH;
         V_MV_NAME := I.NAME;
    UPDATE DISCO_MV_REFRESH_ORDER A SET A.LAST_REFRESH = V_LAST_REFRESH
    WHERE A.MV_OBJECT_NAME = V_MV_NAME;
    COMMIT;
    UPDATE DISCO_MV_REFRESH_ORDER A SET A.REFRESH_STATUS = V_STATUS
    WHERE A.MV_OBJECT_NAME = V_MV_NAME;
    COMMIT;
    END LOOP;
    END Upd_Disco_Mv_Refresh_Order_Tbl;
    Next, I have a "new" procedure that does the job creation and refresh show just below this which, when starting the loop, sets the LAST_REFRESH date in my table to NULL and the STATUS = 'INVALID'. Then if the order of refresh = 1 then it uses SYSDATE to submit the job and start right away, else if it's not the first job, it uses V_NEXT_DATE. Now, V_NEXT_DATE is equal to the LAST_REFRESH date from my table when the view has completed and the V_PREV_STATUS = 'VALID'. I think tack on 2 seconds to that to begin my next job.... See code below:
    CREATE OR REPLACE PROCEDURE Disco_Mv_Refresh IS
    V_FAILURES NUMBER;
    V_JOB_NO NUMBER;
    V_START_DATE DATE := SYSDATE;
    V_NEXT_DATE DATE;
    V_NAME VARCHAR2(30);
    V_PREV_STATUS VARCHAR2(7);
    CURSOR MV_LIST IS SELECT DISTINCT A.ORDER_OF_REFRESH,
                                  A.MV_OBJECT_NAME,
                                  A.LAST_REFRESH,
                                  A.REFRESH_STATUS
                        FROM CATEBS.DISCO_MV_REFRESH_ORDER A
                        WHERE A.ORDER_OF_REFRESH <= 5
                   ORDER BY A.ORDER_OF_REFRESH ASC;
    BEGIN
    FOR I IN MV_LIST
    LOOP
    V_NAME := I.MV_OBJECT_NAME;
    V_FAILURES := 0;
    UPDATE DISCO_MV_REFRESH_ORDER SET LAST_REFRESH = NULL WHERE MV_OBJECT_NAME = V_NAME;
    UPDATE DISCO_MV_REFRESH_ORDER SET REFRESH_STATUS = 'INVALID' WHERE MV_OBJECT_NAME = V_NAME;
    IF I.ORDER_OF_REFRESH = 1
    THEN V_START_DATE := SYSDATE;
    ELSE V_START_DATE := V_NEXT_DATE;
    END IF;
    DBMS_JOB.SUBMIT(V_JOB_NO,'DBMS_MVIEW.REFRESH(' || '''' || V_NAME || '''' || '); BEGIN UPD_DISCO_MV_REFRESH_ORDER_TBL; END;',V_START_DATE,NULL);
    SELECT A.REFRESH_STATUS, A.LAST_REFRESH INTO V_PREV_STATUS, V_NEXT_DATE
    FROM DISCO_MV_REFRESH_ORDER A
    WHERE (I.ORDER_OF_REFRESH - 1) = A.ORDER_OF_REFRESH;
    IF I.ORDER_OF_REFRESH > 1 AND V_PREV_STATUS = 'VALID'
    THEN V_NEXT_DATE := V_NEXT_DATE + (2/86400);
    ELSE V_NEXT_DATE := NULL;
    END IF;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND
         THEN
              IF MV_LIST%ISOPEN
                   THEN CLOSE MV_LIST;
              END IF;
    NULL;
    END Disco_Mv_Refresh;
    My problem is that it doesn't appear to be looping to the next job. It worked succesfully on the first job but not the subsequent jobs (or materialized views in this case).... Any ideas?

  • Invalid SQL Query with DBMS_JOB.SUBMIT inside

    Probably a simple thing, but I can't seem to find the problem in here. I get an error that INVALID SQL STATEMENT. I guess I'm messing something up with the lots of ' chars. If anyone could point out where did I failed I'd be really grateful.
    create or replace
    trigger TR_REFRESH_SCHEMAS
      after create or alter
      on schema
    declare
      tableName         user_tables.table_name%TYPE;
      table_count       number(2);
    begin
      select ora_dict_obj_name
      into tableName
      from dual;
      select  count(table_name)
      into    table_count
      from    user_tables
      where   table_name = tableName;
      if (table_count != 0) then
        execute immediate
          'BEGIN'                     ||
            'DBMS_JOB.SUBMIT'         ||
            '('                       ||
              'job        => '        || table_count      || ','        ||
              'what       => '        || 'INSERT_SCHEMA(' ||  tableName || ');,' ||
              'next_date  => '        || sysdate          || ','        ||
              'interval   => '        || null             ||
            ');'                      ||
          'END;'                      ||
          'COMMIT;'
      end if;
      exception
        when no_data_found then
          raise_application_error(-20020, 'Table ' || tableName || ' not found!');
        when others then
          raise_application_error(-20002, 'Error (' || SQLCODE || '): ' || SQLERRM);
    end;

    I've tried all your recommendations without any success.
    For the dbms_output.put_line:
    - I've found there was a problem with the interval => null. In the final statement it looked like: DBMS_JOB.SUBMIT(1, INSERT_SCHEMA(TEST), 2012-08-31...., ); obviously wrong. Since the default value of interval is NULL I've taken out that parameter.
    For the formatting:
    - Thanks for pointing that out! It was surely a problem with that part, as I've seen when printing the statement.
    execute immediate
          'BEGIN '                    ||
            'DBMS_JOB.SUBMIT'         ||
            '('                       ||
              'job        => '        || table_count        || ','        ||
              'what       => '        || 'INSERT_SCHEMA(''' ||  tableName || ''');,' ||
              'next_date  => '        || sysdate            ||
            ');'                      ||
          'END;'
        );With the qnotation:
    - I get an immediate syntactical error when inserting your code right at the second 'q{' part. On the other hand the first parameter: job is a number type so to_char is meaningless in my opinion.
    The result so far for a CREATE TABLE statement:
    Error starting at line 1 in command:
    create table TESTING
      id varchar2(20) not null,
      text number(8),
      dat blob,
      creat_e date
    Error at Command Line:1 Column:0
    Error report:
    SQL Error: ORA-00604: error occurred at recursive SQL level 1
    ORA-20002: Error (-6550): ORA-06550: line 1, column 77:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
       . ( ) , * % & = - + < / > at in is mod remainder not rem
       <an exponent (**)> <> or != or ~= >= <= <> and or like like2
       like4 likec between || multiset member submultiset
    The symbol ";" was ignored.
    ORA-06550: line 1, column 102:
    PLS-00103: Encountered the symbol "-" when expecting one of the following:
       <an identifier> <a double-quoted delimited-identifier>
       current delete exists prior
    Th
    ORA-06512: at line 32
    00604. 00000 -  "error occurred at recursive SQL level %s"
    *Cause:    An error occurred while processing a recursive SQL statement
               (a statement applying to internal dictionary tables).
    *Action:   If the situation described in the next error on the stack
               can be corrected, do so; otherwise contact Oracle Support.

  • Using APEX_MAIL from within a procedure invoked from DBMS_JOB

    I have done a lot of googling and wasted a couple of days getting nowhere and would appreciate some help. But I do know that in order to use APEX_MAIL from within a DBMS_JOB that I should
    "In order to call the APEX_MAIL package from outside the context of an Application Express application, you must call apex_util.set_security_group_id as in the following example:
    for c1 in (
    select workspace_id
    from apex_applications
    where application_id = p_app_id )
    loop
    apex_util.set_security_group_id(p_security_group_id =>
    c1.workspace_id);
    end loop;
    I have created a procedure that includes the above (look towards the end)
    create or replace procedure VACANCIES_MAILOUT
    (p_application_nbr number,
    p_page_nbr number,
    p_sender varchar2)
    AS
    Purpose: Email all people registerd in MAILMAN [email protected]
    with details of any new vacancies that started listing today.
    Exception
    when no_data_found
    then null;
    when others then raise;
    l_body CLOB;
    l_body_html CLOB;
    l_vacancy_desc VARCHAR2(350);
    to_headline varchar2(200);
    to_org varchar2(100);
    l_vacancies_desc varchar2(2000);
    to_workspace_id number(22);
    CURSOR vacancies_data IS
    select DISTINCT v.headline to_headline,
    ou.org_name to_org
    from VACANCIES v,
    Org_UNITS ou
    where
    ou.org_numb = v.Org_Numb
    and v.public_email_sent_date is Null
    Order by ou.org_name, v.headline;
    BEGIN
    BEGIN
    FOR vacancies_rec in vacancies_data
    -- build a list of vacancies
    loop
    BEGIN
    l_vacancy_desc := '<br><b>' ||
    vacancies_rec.to_org || '<br>' ||
    vacancies_rec.to_headline || '</b><br>';
    -- l_vacancy_desc :=
    -- vacancies_rec.to_org || ' - ' ||
    -- vacancies_rec.to_headline ;
    l_vacancies_desc := l_vacancies_desc || l_vacancy_desc;
    END;
    END LOOP;
    END;
    l_body := 'To view the content of this message, please use an HTML enabled mail client.'||utl_tcp.crlf;
    l_body_html :=
    '<html>
    <head>
    <style type="text/css">
    body{font-family:  Verdana, Arial, sans-serif;
                                   font-size:11pt;
                                   margin:30px;
                                   background-color:white;}
    span.sig{font-style:italic;
    font-weight:bold;
    color:#811919;}
    </style>
    </head>
    <body>'||utl_tcp.crlf;
    l_body_html := l_body_html || l_vacancies_desc
    || '<p>-----------------------------------------------------------------------------------------------------------------</strong></p>'
    ||utl_tcp.crlf
    || '<p>The above new vacancies have been posted on the <strong>Jobs At Murdoch</strong> website.</p>'
    ||utl_tcp.crlf
    ||'<p>For futher information about these vacancies, please select the following link</p>'
    ||utl_tcp.crlf
    ||'<p> Jobs At Murdoch </p>'
    ||utl_tcp.crlf
    ||'<p></p>'
    ||utl_tcp.crlf;
    l_body_html := l_body_html
    ||' Regards
    '||utl_tcp.crlf
    ||' <span class="sig">Office of Human Resources</span>
    '||utl_tcp.crlf;
    for c1 in (
    select workspace_id
    from apex_applications
    where application_id = 1901)
    loop
    apex_util.set_security_group_id(p_security_group_id => c1.workspace_id);
    end loop;
    apex_mail.send(
    p_to => '[email protected]',
    p_from => '[email protected]',
    p_body => l_body,
    p_body_html => l_body_html,
    p_subj => 'Jobs At Murdoch - new vacancy(s) listed');
    update VACANCIES
    set public_email_sent_date = trunc(sysdate,'DDD')
    where public_email_sent_date is null;
    commit;
    END;
    but still get the error
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    ORACLE_HOME = /oracle
    System name: Linux
    Node name: node
    Release: 2.6.18-194.17.1.el5
    Version: #1 SMP Mon Sep 20 07:12:06 EDT 2010
    Machine: x86_64
    Instance name: instance1
    Redo thread mounted by this instance: 1
    Oracle process number: 25
    Unix process pid: 5092, image: (J000)
    *** 2011-07-12 09:45:03.637
    *** SESSION ID:(125.50849) 2011-07-12 09:45:03.637
    *** CLIENT ID:() 2011-07-12 09:45:03.637
    *** SERVICE NAME:(SYS$USERS) 2011-07-12 09:45:03.637
    *** MODULE NAME:() 2011-07-12 09:45:03.637
    *** ACTION NAME:() 2011-07-12 09:45:03.637
    ORA-12012: error on auto execute of job 19039
    ORA-20001: This procedure must be invoked from within an application session.
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 290
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 325
    ORA-06512: at "APEX_040000.WWV_FLOW_MAIL", line 367
    ORA-06512: at "HRSMENU_TEST.VACANCIES_MAILOUT", line 94
    ORA-06512: at line 1
    Can someone please tell me what what stupid thing I am doing wrong? The procedure worked when invokded from SQL Workshop but fails in a DBMS_JOB.
    much thanks Peter

    I think that might help...
    http://www.easyapex.com/index.php?p=502
    Thanks to EasyApex..
    LK

  • How to send e-mail alert to the user job is successful or failed.

    Hi Experts,
    I have scheduled a job using DBMS_JOB Package; in this job I am calling a procedure.
    How can we send an e-mail(alert) to the user if the job is successful (or) job fails.
    If the job is successfully completed, then we have to send mail as “Job is completed successfully along with job name”.
    If the job fails we have to send email as “error message of the job along with job name”(why the job is failed).
    This alert should be sending automatically no manual intervention.
    Please help me.
         CREATE OR REPLACE PROCEDURE APPS_GLOBAL.arc_procedure (P_ID IN NUMBER)
         IS
         CURSOR C IS SELECT id,table_name,archive_table_name,where_condition
         FROM apps_global.control_ram
         WHERE id = p_id
         ORDER BY id, table_name;
         BEGIN
            FOR I IN C
            LOOP
               EXECUTE IMMEDIATE
                  'INSERT INTO '
               || I.ARCHIVE_TABLE_NAME
               || '
         (SELECT * FROM '
               || I.TABLE_NAME
               || ' WHERE '
               || I.WHERE_CONDITION
               || ')';
               EXECUTE IMMEDIATE
                  'DELETE FROM '
               || I.TABLE_NAME
               || ' WHERE '
               || I.WHERE_CONDITION
               || '';
               COMMIT;
            END LOOP;
         EXCEPTION
            WHEN OTHERS
            THEN
               ROLLBACK;
               DBMS_OUTPUT.PUT_LINE (
               'An error was encountered - ' || SQLCODE || ' -ERROR- ' || SQLERRM);
         END arc_procedure;
         /This is my job.
    DECLARE
      X NUMBER;
    BEGIN
      SYS.DBMS_JOB.SUBMIT
      ( job       => X
       ,what      => 'APPS.arc_procedure(1);'
       ,next_date => to_date('05/01/2013 00:00:00','dd/mm/yyyy hh24:mi:ss')
       ,interval  => 'TRUNC(SYSDATE+1)'
       ,no_parse  => FALSE
      SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
    COMMIT;
    END;
    /Thanks in advance.

    Hi,
    I think you can do by creating mailing procedures and call it in the loop and outside the loop.
    There would be two procedure one in inside loop which will execute after successfull completion of the loop.
    Other would be in the exception block like i shown in the below code you have written;
    V_variable_1 you can use as a parameter for what is the error occured.
    like suppose your mailing procedure name is Status_email and Status_email_1.
    CREATE OR REPLACE PROCEDURE APPS_GLOBAL.arc_procedure (P_ID IN NUMBER)
         IS
         CURSOR C IS SELECT id,table_name,archive_table_name,where_condition
         FROM apps_global.control_ram
         WHERE id = p_id
         ORDER BY id, table_name;
    V_VARIABLE_1 NUMBER;
    V_VARIABLE_2 VARCHAR2(400);
         BEGIN
            FOR I IN C
            LOOP
               EXECUTE IMMEDIATE
                  'INSERT INTO '
               || I.ARCHIVE_TABLE_NAME
               || '
         (SELECT * FROM '
               || I.TABLE_NAME
               || ' WHERE '
               || I.WHERE_CONDITION
               || ')';
               EXECUTE IMMEDIATE
                  'DELETE FROM '
               || I.TABLE_NAME
               || ' WHERE '
               || I.WHERE_CONDITION
               || '';
               COMMIT;
                     STATUS_EMAIL;
            END LOOP;
         EXCEPTION OTHERS THEN
    V_VARIABLE_1 :=SQLCODE;
    V_VARIABLE_2 :=SQLERRM;
               ROLLBACK;
    STATUS_EMAIL_1(V_VARIABLE_1,V_VARIABLE_2);
         END arc_procedure;
         / You can refer to sample email procedure i have created for you.
    CREATE OR REPLACE PROCEDURE STATUS_EMAIL
    AS
       v_From       VARCHAR2(80) := 'EMAIL_ID';
       v_Recipient  VARCHAR2(80) := 'EMAIL_ID';
    --YOU CAN SEND EMAIL TO MORE THAT ONE USER SO YOU CAN USE LIKE BELOW VARIABLE....
       v_Recipienttt  VARCHAR2(80) := 'EMAIL_ID';
       v_Subject    VARCHAR2(80) := 'SUBJECT_FOR_THE_MAIL';
       v_Mail_Host  VARCHAR2(30) := 'MAIL_SERVERS_HOST_IP(SMTP_SERVER)';
       v_Mail_Conn  utl_smtp.Connection;
       crlf         VARCHAR2(2)  := chr(13)||chr(10);
    BEGIN
      v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host);
      utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
      utl_smtp.Mail(v_Mail_Conn, v_From);
      utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
      utl_smtp.Rcpt(v_Mail_Conn, v_Recipienttt);
    --OPEN DATA CONNNECTION
      UTL_SMTP.OPEN_DATA(v_mail_conn);
    --MAIL HEADER
      utl_smtp.write_DATA(v_Mail_Conn,'Date: '   || to_char(sysdate, 'DD-MON-YYYY hh:mi:ss AM') || crlf);
      utl_smtp.write_DATA(v_Mail_Conn,'From: '   || v_From || crlf );
      utl_smtp.write_DATA(v_Mail_Conn,'Subject: '|| v_Subject || ||crlf);
      utl_smtp.write_DATA(v_Mail_Conn,'To: '     || v_Recipient || crlf);
      utl_smtp.write_DATA(v_Mail_Conn,'Cc: '       || v_Recipienttt ||','|| crlf);
    --MAIL BODY
      utl_smtp.write_DATA(v_Mail_Conn,'MIME-Version: 1.0'|| crlf );
      utl_smtp.write_DATA(v_Mail_Conn,'Content-Type: multipart/mixed;'|| crlf );
      utl_smtp.write_DATA(v_Mail_Conn,' boundary="-----SECBOUND"'|| crlf ||crlf );
      utl_smtp.write_DATA(v_Mail_Conn,'-------SECBOUND'|| crlf );
      utl_smtp.write_DATA(v_Mail_Conn,'Content-Type: text/plain;'|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,'Content-Transfer_Encoding: 7bit'|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,'Procedure is successfully complited without error'|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,null|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,null|| crlf);
    utl_smtp.write_DATA(v_Mail_Conn,null|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,'Dear All, '|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,'Procedure is successfully complited without error'||'.' ||crlf);
      utl_smtp.write_DATA(v_Mail_Conn,null|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,null|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,null|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,null|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,'Regards, '|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,null|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,'any_name '|| crlf);
      utl_smtp.write_DATA(v_Mail_Conn,null|| crlf);
      utl_smtp.write_data(v_Mail_Conn, utl_tcp.CRLF ||'This mail is auto generated.');
      --CLOSE CONNECTION
      UTL_SMTP.CLOSE_DATA(v_mail_conn);
      utl_smtp.Quit(v_mail_conn);
    EXCEPTION
      WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
        raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;
    /cheers..

  • Oracle 8.0.5.1 EE DBMS_JOB Problem

    I am running Oracle 8.0.5.1 EE on Redhat Linux version 6.1 with the glibcpatch applied.
    I have come across a problem with regular execution of submitted jobs.
    I submit a job(any job) and when execution time comes, it fails. I have dbms_job setup correctly for the database. The init.ora parameters are set correctly and the snp process is running.
    I know the job is valid because I can force a job to run using the dbms_job.run procedure.
    This tells me everything is running fine. However, when the execute time is reached, the user_jobs table shows a failure.
    I have tried the same exact procedure and job on Oracle 8.0.5 EE on Solaris and it works fine.
    I am at a loss of what to do next to resolve this issue.
    Any help would be greatly appreciated.
    Thanks
    Christopher Fitch
    null

    Hi,
    I also had a problem with these scripts.
    Try : dos2unix oratab.sh and/or dos2unix orainst.sh
    (and chmod u+x oratab.sh)
    bye
    Laurent
    Andy Hanas (guest) wrote:
    : I must be doing something wrong that's really basic. I'm
    : attempting to install Oracle 8.0.5.1 on OpenLinux 2.2. I've
    : done everything the documentation has said, but I cannot get
    the
    : oratab.sh script to run (so, I've really gotting no where).
    : When I attempt to run the script I get the follwing:
    : bash$ sh oratab.sh
    : : command not found
    : : command not found
    : : command not found
    : : command not found
    : : command not found
    : : command not found
    : : command not found
    : : command not found
    : 'ratab.sh: syntax error near unexpected token `in
    : 'ratab.sh: oratab.sh: line 30: `case ${N}$C
    : in
    : Any ideas on what I'm doing wrong or how I can debug this
    thing?
    : Thanks for any help!
    null

  • Help in Understanding DBMS_JOB.SUBMIT

    Hi,
    I trying DBMS_JOB.SUBMIT for the first time and i am unable to figure out what is wrong in my code as i dont find any errors.
    I have a Procedure Pro_job which has DBMS_JOB.SUBMIT which inturn calls an procedure.
    here is the code.
    CREATE OR REPLACE procedure Pro_job( P_Number1 IN Number) is
    jobno number;
    Begin
    DBMS_JOB.SUBMIT(job=>jobno,
    what => 'P_T.Proc_T(''P_Number1'');');
    dbms_output.put_line(P_Number1);
    dbms_output.put_line(jobno);
    End;
    When i compled there are no erros, but this DBMS_JOB.SUBMIT is not triggering or running P_T.Proc_T. And also i want it to run only once with out NEXT_DATE schedule. When i see in DBA_JOBS_RUNNING I find that the job is getting scheduled to run again for the same jobno. which i dont want evern if it fails. Thats the reason why i havnt given any Next_Date in DBMS_JOB.SUBMIT, but still it takes.
    Select * from DBA_JOBS_RUNNING
    I dont understand which i went work. Can someone guide me on this issue.
    Thanks
    Sami

    You say that it's not triggering or running P_T.Proc_T.
    How do you know?
    Is it because you can't see the effects of that proc?
    You also say that you can see it in DBA_JOBS_RUNNING and that it's getting rescheduled.
    This means that the submit has worked.
    It also sounds very much like the job is failing.
    If the job fails it will retry a number of times before getting set to broken.
    If you put some logging in what you're calling (the logging in an autonomous transaction perhaps), it might be more obvious what's happening.
    Here's a standalone example of submitting a job, and it running:
    SQL> drop table job_test;
    Table dropped.
    SQL> create table job_test
      2  (col1 date);
    Table created.
    SQL>
    SQL> create or replace procedure p_job_test
      2  as
      3  begin
      4    insert into job_test
      5    values(sysdate);
      6    commit;
      7  end;
      8  /
    Procedure created.
    SQL> select * from job_test;
    no rows selected
    SQL>
    SQL> declare
      2   l_job integer;
      3  begin
      4   dbms_job.submit(l_job,'p_job_test;');
      5   commit;
      6  end;
      7  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select * from job_test;
    no rows selected
    SQL> select * from job_test;
    COL1
    02-FEB-11
    SQL> select * from user_jobs;
    no rows selected
    SQL>

  • Schedule a job using dbms_job package

    SQL to schedule a job using DBMS_JOB.
    variable jobno number;
    variable status number;
    begin
    dbms_job.submit(:jobno, 'x(:status);', trunc(sysdate)+8/24,
    'trunc(sysdate)+1+8/24', null);
    commit;
    end;
    It fails and returns the following error ...
    ORA-01008: not all variables bound
    Is it possible to schedule a job to run a procedure with "IN OUT" parameter? I would appreciate any assistance.
    Proc runs if I execute it from command mode and there are no issues.

    You cannot pass parameters back from a job-- Oracle spawns a separate session to run your job, so that session would receive any OUT parameters and end immediately after the job finishes. Even if Oracle let you do this, you would lose the OUT value as soon as the job ended.
    If you want a job to return a status, you can-
    1) Store the status in a table
    2) Queue a status message in an Oracle Advanced Queue
    3) Use dbms_alert to alert another process
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Using dbms_job but it can't start automatically

    I want to use dbms_job for job scheduling in Oracle 8i but got some serious problem.
    [Question 1]
    If I execute dbms_job like following, I've error :
    [Execute]
    dbms_job.submit(jobno,
    'my_proc',
    sysdate,
    'sysdate + 1/86400');
    [Error]
    declare
    ERROR at line 1:
    ORA-06550: line 1, column 149:
    PLS-00103: Encountered the symbol "END" when expecting one of the following:
    := . ( % ;
    The symbol ";" was substituted for "END" to continue.
    ORA-06512: at "SYS.DBMS_JOB", line 72
    ORA-06512: at "SYS.DBMS_JOB", line 140
    ORA-06512: at line 18
    If I execute dbms_job like following, I've n o error message.
    [Execute]
    ----------------------------------dbms_job.submit(jobno,
    'my_proc',
    sysdate,
    'sysdate + 1/86400',
    true,
    123,
    true);
    How come it is required to input such default parameter.
    [Question 2]
    Even I can submit the job successfully, it can't run automatically.
    If I try to force it to run by executing dbms_job.run(jobno, true), I've the following error :
    [Error]
    ERROR at line 1:
    ORA-12011: execution of 1 jobs failed
    ORA-06512: at "SYS.DBMS_IJOB", line 394
    ORA-06512: at line 1
    My config for my server is like this :
    job_queue_processes = 2
    job_queue_interval = 1
    By checking the value from user_jobs, I found that next_date, next_sec are not refreshed and with broken = 'N' and failures = 0.
    Sometimes if I restart the server or compile the what "my_proc", the job run automatically.
    Can anyone help me to solve it ?
    Rgds,
    Edward
    null

    I've found syntax error in your code.
    You forgot to put ';' after the call(my_proc) to the procedure. It should look like as mentioned
    below.
    dbms_job.submit(jobno,
    'my_proc;',
    sysdate,
    'sysdate + 1/86400');
    It should work now.
    null

Maybe you are looking for