DBMS_JOB, how to execute a script every day at 06 am

Hi
I want to execute a job every day at 06:00 am. To do this, I have run this script yesterday the 26th.
DECLARE
X NUMBER;
BEGIN
SYS.DBMS_JOB.SUBMIT
( job => X
,what => 'begin
tools.followup(1); tools.purge (20);
end;'
,next_date => to_date('27/05/2009 06:00','dd/mm/yyyy hh24:mi:ss')
,interval => TRUNC(SYSDATE+1)+6/24
,no_parse => FALSE
SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
COMMIT;
END;
The problem is that after the first execution next_date was 27th 06:02 !!!!
Is it a bug ?
Thanks in advance
A.G.

No it is not a bug it is a feature. :-) Oracle job calculates it's next running time after it was completed* and therefore tends to move forward in time as time goes by. I saw a badly managed system where a job formerly scheduled on midnight ended running at 9 a.m. in the biggest workload peak, obviously causing some surprise to the management and embarrassment to DBA responsible for the system. While it is possible to get over this feature and have your jobs scheduled precisely, it is more wise to move to DBMS_SCHEDULER, which is way more powerful tool and preferred way to schedule database (and other) jobs now.
* From Oracle9i Database Administrator's Guide: INTERVAL - Alters the interval BETWEEN executions for a specified job.

Similar Messages

  • How to execute sql scripts from Powershell across multiple databases

    Re: How to execute sql scripts from Powershell across multiple databases
    I have an tsql script that I want to run across a list of databases. How is the best way to do this in Powershell? Thanks.

    My example below, using just the SMO and not breaking up the batches, the ExecuteWithResults give the following error when the .sql file contains a GO. My script files are as simple as a DECLARE and then a GO.
    WARNING: SQL Script Failed
    The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid or not in the correct sequence. This is likely caused by a user-specified "format-list" comm
    and which is conflicting with the default formatting.
        + CategoryInfo          : InvalidData: (:) [out-lineoutput], InvalidOperationException
        + FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
    Also, when executing from the ISE, is there a way to force the ISE to release the files. I am having to close the ISE and reopen my script every time I want to make a testing change to the .sql file.
    [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
    $scriptspath = "C:\temp\psExecuteSQLScripts\scripts"
    $SQLServer = "fidevc10"
    $SQLDB = "Bank03"
    # Create SMO Server Object
    $Server = New-Object ('Microsoft.SQLServer.Management.Smo.Server') $SQLServer
    # Get SMO DB Object
    $db = $Server.Databases[$SQLDB]
    # Load All SQL Scripts in Directory
    $scripts = Get-ChildItem -Path (Join-Path $scriptspath "*") -Include "*.sql" -Recurse
    # Loop through each script and execute
    foreach ($SQLScript in $scripts)
    $fullpath = $SQLScript.FullName
    # Read the Script File into Powershell Memory
    $reader = New-Object System.IO.StreamReader($fullpath)
    $script = $reader.ReadToEnd()
    # Execute SQL
    Write-Host "Executing $SQLScript on $SQLDB...."
    try
    $ds = $db.ExecuteWithResults($script)
    Foreach ($t in $ds.Tables)
    Foreach ($r in $t.Rows)
    Foreach ($c in $t.Columns)
    Write-Host $c.ColumnName "=" $r.Item($c)
    Write-Host "Complete"
    catch [Exception]
    Write-Warning "SQL Script Failed"
    echo $_.Exception|format-list -force
    Write-Host " " -BackgroundColor DarkCyan

  • How to execute SQL scripts in batch

    Hi,
    I have separate scripts for Creation of Tables, Stored Procedures, Views, Triggers in different .sql files.
    I have to execute thses scripts in batch in different servers and different databases without opening SSMS.
    All .sql files to be executed in single command.
    Please suggest how to achieve?
    Appreciate your help.
    Regards,
    Bala

    you can use sqlcmd
    https://msdn.microsoft.com/en-us/library/ms162773.aspx
    other options are osql,isql
    https://technet.microsoft.com/en-us/library/aa214012%28v=sql.80%29.aspx
    https://technet.microsoft.com/en-us/library/aa214007%28v=sql.80%29.aspx
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to execute a script using ombplus

    hi
    i have created one scripts using umbplus now i want to execute that scripts using ombplus editor...
    can any one pls let me know how to execute that using ombplus editor..
    thanks
    keka.

    hi,
    we have created a batch file say a.bat and in that batch file we have given the ombplus path "C:\oracle\OWBHome\owb\bin\win32\OMBPlus.bat" and the path of the script file " C:\OWB\test.tcl". if you run the a.bat file its connecting to ombplus but the script is not executing.
    let me know how to achive this??
    thanks.

  • Create or replace synonym ... how to execute the script.

    I have the scripts that creates synonyms and i need to execute these scripts from SQL Plus.
    I want to pass the &owner_user value as an argument, but the script still comes back and asking for the owner_name.
    create or replace synonym V_REPORTS_USAGE for &owner_user..V_REPORTS_USAGE;
    create or replace synonym V_STATION_USAGE for &owner_user..V_STATION_USAGE;
    How do i execute these scripts.
    Thanks
    -Prasad

    it is working for me.
    Try to give user name and object name
    SQL> select * from v$version
      2  ;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
    PL/SQL Release 9.2.0.4.0 - Production
    CORE    9.2.0.3.0       Production
    TNS for Solaris: Version 9.2.0.4.0 - Production
    NLSRTL Version 9.2.0.4.0 - Production
    SQL>
      1*  create or replace  synonym  emp_temp for &emp
    SQL> /
    Enter value for emp: xxxx.emp
    old   1:  create or replace  synonym  emp_temp for &emp
    new   1:  create or replace  synonym  emp_temp for xxxt.emp
    Synonym created.
    SQL>

  • How to execute CLP scripts from db13

    Does any one know how to execute the CLP scripts from db13.

    In Release 7.0 (where  you can define customer specific CLP scripts via db6cockpit ->Jobs-> CLP Script Maintenance" ), in DB13 you have the action "CLP script". Under "action parameters" you can then specify the name of the script, which you had defined before.
    Under Rel. 6.20 the possibility for CLP scripts  seems to be not yet implemented (or could depend on  basis supportpackages? )
    Kind Regards,
    Uta

  • How to execute SQL Script using windows powershell(using invoke-sqlcmd or any if)

    OS : Windows server 2008
    SQL Server : SQL Server 2012
    Script: Test.sql (T-SQL)  example : "select name from sys.databases"
    Batch script: windows  MyBatchscript.bat ( here connects to sql server using sqlcmd  and output c:\Testput.txt) 
     (sqlcmd.exe -S DBserverName -U username -P p@ssword -i C:\test.sql -o "c:\Testoutput.txt)  ---it working without any issues.....
    This can execute if i double click MyBatchscript.bat file and can see the output in c:\testput.txt.
    Powershell: Similarly, How can i do in powershell 2.0 or higher versions?  can any one give full details with each step?
    I found some of them online, but nowhere seen clear details or examples and it not executing through cmd line (or batch script).
    example: invoke-sqlcmd -Servernameinstance Servername -inputfile "c:\test.sql" | out-File -filepath "c:\psOutput.txt"  --(call this file name MyTest.ps1)
    (The above script working if i run manually. I want to run automatic like double click (or schedule with 3rd party tool/scheduler ) in Batch file and see the output in C drive(c:\psOutput.txt))
    Can anyone Powershell experts give/suggest full details/steps for this. How to proceed? Is there any configurations required to run automatic?
    Thanks in advance.

    Testeted the following code and it's working.....thanks all.
    Execute sql script using invoke-sqlcmd with batch script and without batch script.
    Option1: using Import sqlps
    1.Save sql script as "C:\scripts\Test.sql"  script in side Test.sql: select name from sys.databases
    2.Save Batch script as "C:\scripts\MyTest.bat" Script inside Batch script:
    powershell.exe C:\scripts\mypowershell.ps1
    3.Save powershell script as "C:\scripts\mypowershell.ps1"
    import-module "sqlps" -DisableNameChecking
    invoke-sqlcmd -Servername ServerName -inputFile "C:\scripts\Test.sql" | out-File -filepath "C:\scripts\TestOutput.txt"
    4.Run the Batch script commandline or double click then can able to see the output "C:\scripts\TestOutput.txt" file.
    5.Connect to current scripts location  cd C:\scripts (enter)
    C:\scripts\dir (enter )
    C:\scripts\MyTest.bat (enter)
    Note: can able to see the output in "C:\scripts" location as file name "TestOutput.txt".
    Option2: Otherway, import sqlps and execution
    1.Save sql script as "C:\scripts\Test.sql"  script in side Test.sql: select name from sys.databases
    2.Save powershell script as "C:\scripts\mypowershell.ps1"
    # import-module "sqlps" -DisableNameChecking #...Here it not required.
    invoke-sqlcmd -Servername ServerName -inputFile "C:\scripts\Test.sql" | out-File -filepath "C:\scripts\TestOutput.txt"
    3.Connect to current scripts location
    cd C:\scripts (enter)
    C:\scripts\dir (enter )
    C:\scripts\powershell.exe sqlps C:\scripts\mypowershell.ps1 (enter)
    Note: can able to see the output in "C:\scripts" location as file name "TestOutput.txt".

  • How to execute a script(.sql) file from a PL\SQL procedure

    I would like to know how to execute a .sql file from a stored procedure and the result of it should update a table. My .sql file contains select statements.

    Hi!
    just go through the following piece of code -
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    str varchar2(200);
      3  begin
      4    str := '@C:\RND\Oracle\Misc\b.sql';
      5    execute immediate(str);
      6* end;
    SQL> /
    declare
    ERROR at line 1:
    ORA-00900: invalid SQL statement
    ORA-06512: at line 5ORA-00900: invalid SQL statement
    Cause: The statement is not recognized as a valid SQL statement. This error can occur if the Procedural Option is not installed and a SQL statement is issued that requires this option (for example, a CREATE PROCEDURE statement). You can determine if the Procedural Option is installed by starting SQL*Plus. If the PL/SQL banner is not displayed, then the option is not installed.
    Action: Correct the syntax or install the Procedural Option.
    Regards.
    Satyaki De.

  • How to schedule a job every day night 12:05AM EST in the KnowledgeManagemen

    I have created the scheduler to run every day night 12:05AM EST in the KnowledgeManagement->ContetntManagement->Globelservices->Schedulertask. But it was running every day mid day at 12:05PM. I have created the new entry in the scheduler timetable as 'EveryDayAt2405' I have selected the Hour as '12AM' Minute as '5' and Time Zone-'GMT-05:00 (America/New York) Eastern Standard Time'.
    Please help on this issue
    Thanks In Advance
    Regards,
    srini

    I have fixed this issue to run the scheduler at 12AM need to select the 12PM . Internally it will take the 12AM as Zero hours

  • How to execute vb script with out using Remote manager in oim 11g r2

    Hi Currently,
    i have a requirement to execute  vb script (present on a remote machine in which connector server is installed) from oim machine while using Exchange connector (11.1.1.6).
    This can be achieved by using remote manager,but i dont want to use remote manager.
    Hence decided to use Action scripts.
    As per connector configuration,
    i have configured Action scripts in Lookup.Exchange.UM.Configuration lookup definition, by means of three entries
    After Create Action Language      Shell
    After Create Action Target           Resource
    After Create Action File              /home/scripts/Disable.bat
    Disable.bat has the following ,
    Powershell.exe -File C:\scripts\Setup.vbs
    -%Log on Name%
      Exit
    As Setup.vbs is expecting a parameter of log on name, i was providing the same.
    But while creating the user,as this script gets called, getting the following error and hence 'create User' is getting failed.
    Problem while PowerShell execution System.Management.Automation.RemoteException: This task does not support recipients of this type. The specified recipient XXXXXXXXXXX...XXXXX is of type UserMailbox. Please make sure that this recipient matches the required recipient type for this task.
    While provisioning the user to Exchange , i have selected 'Recepient type' as 'User Mail box' explicitly, but still getting the error.
    Please provide any pointers to resolve the issue.
    Thanks in advance
    Kumar

    As far as I know Oracle and MySQL are two different products.
    Why do you clutter an Oracle forum with MySQL questions?
    If MySQL is such a tremendous RDBMS, like many people state (as 'free' means per definition better),
    why don't you visit a MySQL forum where fellow MySQL aficionados can answer you MySQL questions?
    In short, why don't you stop abusing Oracle forums?
    Sybrand Bakker
    Senior Oracle DBA

  • How to execute SAPGUI script from the command line?

    I have created a script and would like to execute it from the command line. There must be some flag that goes with SAPGUI.EXE. Any help appreciated.
    Thanks,
    Jeff

    Hi Jeff,
    the best way to do this is to run the script using the Windows Script Host, for example like this:
    cscript myscript.vbs
    This will execute the script which in turn can access SAP GUI. You may however have to make sure the script attaches to the correct session.
    Best regards,
    Christian

  • How does execute PHP Script from SAP?

    I've already installed SAPRFC and run SAP Function from PHP successfully. But failed when tried execute PHP script from SAP (SM59). Anyone can help me for a clear instruction for this problem?
    Thanks

    Hi Max,
    here is the Source:
    [code]
    #!/usr/bin/php -q
    <?php
    // SAPRFC - Server example
    // PHP server function RFC_READ_REPORT
    // Require: CGI version PHP, RFC destination defined in SAP R/3 (SM59)
    // http://saprfc.sourceforge.net
    // Interface definiton for RFC_READ_REPORT
    // (generated by saprfc.php - option Generate PHP)
       $DEF_RFC_READ_REPORT = array (
                             array (
                                     "name"=>"SYSTEM",
                                     "type"=>"EXPORT",
                                     "optional"=>"0",
                                     "def"=> array (
                                             array ("name"=>"","abap"=>"C","len"=>8,"dec"=>0)
                             array (
                                     "name"=>"TRDIR",
                                     "type"=>"EXPORT",
                                     "optional"=>"0",
                                     "def"=> array (
                                             array ("name"=>"NAME","abap"=>"C","len"=>40,"dec"=>0),
                                             array ("name"=>"SQLX","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"EDTX","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"VARCL","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"DBAPL","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"DBNA","abap"=>"C","len"=>2,"dec"=>0),
                                             array ("name"=>"CLAS","abap"=>"C","len"=>4,"dec"=>0),
                                             array ("name"=>"TYPE","abap"=>"C","len"=>3,"dec"=>0),
                                             array ("name"=>"OCCURS","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"SUBC","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"APPL","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"SECU","abap"=>"C","len"=>8,"dec"=>0),
                                             array ("name"=>"CNAM","abap"=>"C","len"=>12,"dec"=>0),
                                             array ("name"=>"CDAT","abap"=>"D","len"=>8,"dec"=>0),
                                             array ("name"=>"UNAM","abap"=>"C","len"=>12,"dec"=>0),
                                             array ("name"=>"UDAT","abap"=>"D","len"=>8,"dec"=>0),
                                             array ("name"=>"VERN","abap"=>"C","len"=>6,"dec"=>0),
                                             array ("name"=>"LEVL","abap"=>"C","len"=>4,"dec"=>0),
                                             array ("name"=>"RSTAT","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"RMAND","abap"=>"C","len"=>3,"dec"=>0),
                                             array ("name"=>"RLOAD","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"FIXPT","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"SSET","abap"=>"C","len"=>1,"dec"=>0),
                                             array ("name"=>"SDATE","abap"=>"D","len"=>8,"dec"=>0),
                                             array ("name"=>"STIME","abap"=>"C","len"=>6,"dec"=>0),
                                             array ("name"=>"IDATE","abap"=>"D","len"=>8,"dec"=>0),
                                             array ("name"=>"ITIME","abap"=>"C","len"=>6,"dec"=>0),
                                             array ("name"=>"LDBNAME","abap"=>"C","len"=>20,"dec"=>0)
                             array (
                                     "name"=>"PROGRAM",
                                     "type"=>"IMPORT",
                                     "optional"=>"0",
                                     "def"=> array (
                                             array ("name"=>"","abap"=>"C","len"=>40,"dec"=>0)
                             array (
                                     "name"=>"QTAB",
                                     "type"=>"TABLE",
                                     "optional"=>"0",
                                     "def"=> array (
                                             array ("name"=>"LINE","abap"=>"C","len"=>72,"dec"=>0)
    // Create list of PHP server functions
       $GLOBAL_FCE_LIST[RFC_READ_REPORT] = saprfc_function_define(0,"RFC_READ_REPORT",$DEF_RFC_READ_REPORT);
    // PHP server function
       function RFC_READ_REPORT ($fce)
           $REPORT = saprfc_server_import ($fce,"PROGRAM");
           saprfc_table_init ($fce,"QTAB");
           $fd = fopen ($REPORT,"r");
           if (!$fd)
               return ("NOTFOUND");     // raise exception "NOTFOUND"
           while (!feof($fd))
               $LINE = fgets ($fd,73);
               saprfc_table_append ($fce,"QTAB",array("LINE"=>$LINE));
           fclose ($fd);
           saprfc_server_export ($fce,"SYSTEM","PHP");
           return (true);
    // Call script with: ./server.php -a phpgw -g hostname -x sapgw00
       $rfc = saprfc_server_accept ($argv);
    // Dispatch one function call
       $rc = saprfc_server_dispatch ($rfc,$GLOBAL_FCE_LIST);
       saprfc_close ($rfc);
    ?>
    [/code]
    Regards
    Gregor
    Message was edited by: Gregor Wolf

  • How to execute sql script from linux command line

    Hello everyone !
    Just short question. On my server I must install script in crontab which will eexecute some sql statements.
    How can I write command which will execute script from file without asking about password ?
    sqlplus user/pass ... and then what ?
    thanks
    dlugasx

    user10064952 wrote:
    Just short question. On my server I must install script in crontab which will eexecute some sql statements.
    How can I write command which will execute script from file without asking about password ?Crontab does not run your local shell profile - which means no valid Oracle environment for SQL*Plus to execute in.
    On newer cron versions, you can add an environment to the crontab file itself that needs to be set before executing the scheduled command.
    Whatever method - make sure you have ORACLE_HOME set, that the path includes ORACLE_HOME/bin, that ORACLE_SID is set (if not using a TNS alias) and so on.
    But I agree with Sybrand... crontab is not the best place for running SQL or PL/SQL code. That should reside in the database as named code (e.g. stored procs) and be executed via DBMS_JOB or DBMS_SCHEDULE.
    Less moving parts that way. No external dependancies. And will work on any Oracle server, irrespective of the o/s used and whether or not the relevant o/s user has batch/cron/etc privs to do the deed.

  • How will execute shell scripts from AR91

    hallo, please help me to find where I can configure the execution mode for scripts called als run-Script in acroread.
    Following scenario: a pdf file (see attachement testpdf.pdf), generate from pdflatex (see testpdf.tex.txt) calls a bash script beispiel.sh (see attachement beispiel.sh.txt). Dependend from situation opens an editor window or an xterm. Under GNOME can we not open the xterm, there start only editor windows - gvim/emacs/kwrite, but not well defined. With acroread7 opens a xterm after menu dialogs. How can i configure an defined behaviour ?
    Thanx for any help
    Regards, Matthias

    Hi Matthias,
    To achieve this you can try to change the default "Open With" settings of .sh files to "xterm" as highlighted in the snapshot below
    This will enable to execute any shell script in xterm.
    Let us know if this helps.
    Thanks,
    Vaibhav

  • How to execute SQL scripts with MaxDB ..?

    Hi all,
    i got some clue from another thread and i observed the command is like
    sqlcli -d DBNAME -u SQLUSER,SQLPASS -i filename.sql -c <delimiter> is there,
    when i use this the only first query is successfully executing,
    this might be problem with delimiter.
    can any body help how to use delimiter in the script file with an example.
    thanks in advance.
    --Hari

    Hi,
    Sample Script
    CREATE TABLE city
    (zip                CHAR (5)    KEY CONSTRAINT zip BETWEEN '10000' AND '99999',
    name               CHAR(20)    NOT NULL,
    state              CHAR(2)     NOT NULL)
    CREATE TABLE customer
    (cno                FIXED (4)   KEY CONSTRAINT cno BETWEEN 1 AND 9999,
    title              CHAR (7)    CONSTRAINT title IN ('Mr', 'Mrs', 'Company'),
    firstname          CHAR (10)   ,
    name               CHAR (10)   NOT NULL,
    zip                CHAR (5)    CONSTRAINT zip BETWEEN '10000' AND '99999',
    address            CHAR (25)   NOT NULL,
    FOREIGN KEY (zip) REFERENCES city ON DELETE RESTRICT)
    \dt customer
    COMMIT
    Regards
    Ayyapparaj

Maybe you are looking for

  • Stroing PIN's

     How does any store PIN's on their Blackberry's Do you just add them to you contact list information??

  • Amd 970A-G46 3.0 usb connection

    Hi I'm building my computer for the first time and can't locate the 3.0 usb location on the mobo. I have a cool master elite 431 case with a 3.0 usb cable but I don't know where to connect. Any help is appreciated. Thanks!

  • Flash lite in browser for nokia 6233?

    hai, can U help me? i use nokia 6233 but flashlite not desplay in my web browser what is the content type in device setting > browser ?

  • Help, I am trying to download a fresh copy of photo shop 10 onto my desktop but i keep getting error codes

    I  originally had  photo shop 10  on my laptop but my laptop no longer works, so I am trying to download a copy onto my desktop. .  I keep getting an error code and a message that reads:Access Denied  You don't have permission to access "http://trial

  • Problems With Project In Opera?

    I created this project in Edge and it doesn't work in Opera??? http://www.meschrene.puremadnessproductions.net/Samples/Video/Sync-Content/Nature-B.html http://www.meschrene.puremadnessproductions.net/Samples/Video/Sync-Content/Nature-B.zip When the v