ORACLE JOB

Hi
A small help..!!
I have a table with two columns.
col1        char(2)   ... values   y or n
col2        number(2); values   1 or 0
Now I have to create a job on these columns..the job executes on every day midnight 2 a.m. In this job
I have to update col1 values as 'N' wherever 'Y' occurs. and I have to update col2 as 0 whereever 1 occurs. Please give me sample code on this...!! it is very nice of you..
thanks in adv.
Sa

What version of Oracle are you using?
What does "every day midnight 2 a.m." mean? Midnight and 2 AM are different times. Do you want it to run at twice a day?
I'm guessing that you want something like
CREATE PROCEDURE update_your_table
AS
BEGIN
  UPDATE your_table
     SET col1 = 'N'
   WHERE col1 = 'Y';
  UPDATE your_table
     SET col2 = 0
   WHERE col2 = 1;
END;
DECLARE
  l_jobno pls_integer;
BEGIN
  dbms_job.submit(
    l_jobno,
    'BEGIN update_your_table; END;',
    trunc(sysdate+1),
    'trunc(sysdate+1)'
  commit;
END;Depending on the Oracle version, you may want to use the more powerful DBMS_SCHEDULER package rather than the old DBMS_JOB package.
Justin

Similar Messages

  • Error faced while creating Oracle Job

    Hi,
    I have the following script to create a job.
    It executed successfully on my database. When we tried to execute the same at our clients place we got some error,
    ===========================================
    SQL> DECLARE
    2 job NUMBER;
    3 m_sleeptimegap NUMBER;
    4 job_interval VARCHAR2(100);
    5
    6
    7 BEGIN
    8 SELECT to_number(tdvalue)
    9 INTO m_sleeptimegap
    10 FROM tabledetails
    11 WHERE tdidcode = 'LICENSE_PULSE'
    12 AND tdkey = 'STATUS_DELAY';
    13
    14 job_interval := 'SYSDATE +'|| m_sleeptimegap / 86400;
    15
    16 DBMS_JOB.SUBMIT(job, 'License_Pulse_Check;', SYSDATE, job_interval, 'FALSE');
    17 UPDATE tabledetails
    18 SET tdvalue = LTRIM( RTRIM( TO_CHAR(job) ) )
    19 WHERE tdidcode = 'LICENSE_PULSE'
    20 AND tdkey = 'ORACLE-JOB-ID';
    21 COMMIT;
    22 END;
    23 /
    DECLARE
    ERROR at line 1:
    ORA-23319: parameter value "SYSDATE
    +,000347222222222222222222222222222222222222" is not appropriate
    ORA-06512: at "SYS.DBMS_JOB", line 60
    ORA-06512: at "SYS.DBMS_JOB", line 138
    ORA-06512: at line 16
    ===========================================
    'm_sleeptimegap' is = 30 , which we have configured in a table called "tabledetails".
    This is present at the client's place.
    What could be the reason of this script failure ?
    Could it be grants issue or something else ?
    Thanks.

    Hi,
    But that parameter in the dbms_job.submit procedure is of VARCHAR2 type,
    dbms_job.submit(
    JOB OUT BINARY_INTEGER,
    WHAT IN VARCHAR2,
    NEXT_DATE IN DATE DEFAULT SYSDATE,
    INTERVAL IN VARCHAR2 DEFAULT 'NULL',
    NO_PARSE IN BOOLEAN DEFAULT FALSE,
    INSTANCE IN BINARY_INTEGER DEFAULT 0,
    FORCE IN BOOLEAN DEFAULT FALSE);
    [http://www.psoug.org/reference/dbms_job.html?PHPSESSID=5a94d055d8b65bd4b4661d1d24dedbf8]
    Thanks.

  • Oracle Job not running properly

    Hi All,
    I am facing an issue with oracle jobs.
    I have writtent the script of a job scheduled to be executed automatically after 2 seconds.It works on a table and dequeue the data in that table.
    Now the job is not able to execute for next time.If i execute the job immediately then also it does not run for next time.
    so where could be the problem...
    Please give me pointers.
    Thanks in advance :)
    Thanks n Regards
    Arun

    user10280915 wrote:
    Hi All,
    I am facing an issue with oracle jobs.
    I have writtent the script of a job scheduled to be executed automatically after 2 seconds.It works on a table and dequeue the data in that table.
    Now the job is not able to execute for next time.If i execute the job immediately then also it does not run for next time.
    so where could be the problem...
    Please give me pointers.
    Thanks in advance :)
    Thanks n Regards
    ArunThings that you'll need.
    1. JOB_QUEUE_PROCESSES to be non-zero
    2. A commit after submitting the job
    3. The job not to be broken.
    4. don't schedule very frequently (say <5s) if the os is Linux :( ).
    I'd check in the above order.
    Niall

  • Drop/Create sequence using Oracle Job Scheduler

    IDE for Oracle SQL Development: TOAD 9.0
    Question: I am trying to do the following:
    1. Check if a certain sequence exists in the user_sequences table
    2. Drop the sequence if it exists
    3. Re-create the same sequence afterward
    All in a job that is scheduled to run daily at 12:00 AM.
    What I would like to know is if this is even possible in the first place with Oracle jobs. I tried the following:
    1. Create the actual "BEGIN...END" anonymous block in the job.
    2. Create a procedure that uses a dynamic SQL string using the same "BEGIN...END" block that drops and recreates the sequence using the EXECUTE IMMEDIATE commands
    But I have failed on all accounts. It always produces some sort of authorization error which leads me to believe that DDL statements cannot be executed using jobs, only DML statements.
    BTW, by oracle jobs, I mean the SYS.DBMS_JOBS.SUBMIT object, not the job scheduler.
    Please do not ask me why I need to drop and recreate the sequence. It's just a business requirement that my clients gave me. I just want to know if it can be done using jobs. If not, I would like to know if there are any work-arounds possible.
    Thank you.

    Please do not ask me why I need to drop and recreate the sequence. It's just a business requirement that my clients gave me. I just want to know if it can be done using jobs. If not, I would like to know if there are any work-arounds possible.Well, I won't ask you then, but can you ask your clients why on earth they would want that?
    Do they know that doing DDL 'on the fly' will invalidate the dependent objects?
    Best shot you can give at it is reset the sequence. And you could do it in a job, yes, as long as it's interval is during some maintenance window (no active users).
    Regarding resetting a sequence, you, (and your clients) should read this followup:
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:1119633817597
    (you can find lots more info on sequences and jobs by doing a search from the homepage http://asktom.oracle.com)
    Regarding the authorization errors: your DBA should be able to provide you the nessecary privileges.
    But in the end, this is something I'd rather not would like to see implemented on a production system...

  • Date and Time issue oracle job

    i have wriited oracle job to execute my procedure and the job has to execute the procdedure at 11:30 pm every day.
    following are the parameters of the JOB.
    next_date => TRUNC(SYSDATE) + 23/24+ 0.5/24
    interval  => 'SYSDATE + 1'
    But it is not executing the procedure at 11.30 pm everydat. Waht coud be wrong in the schedule part. please help me in this.

    Hi,
    born2win wrote:
    i have wriited oracle job to execute my procedure and the job has to execute the procdedure at 11:30 pm every day.
    following are the parameters of the JOB.
    next_date => TRUNC(SYSDATE) + 23/24+ 0.5/24
    interval  => 'SYSDATE + 1'
    But it is not executing the procedure at 11.30 pm everydat. Waht coud be wrong in the schedule part. please help me in this.When you use SYSDATE in the interval parameter, it is the time when the job finishes , not the time when the job begins (which may not be the time you wanted the job to begin, if the database is down).
    If, regardless of when a job finishes, you want it to run again at 11:30 PM the next day, then use
    interval  => 'TRUNC (SYSDATE) + 1 + (23.5 / 24)'Unless you're using a very old version of Oracle, you should use dbms_scheduler instead of dbms_job. See
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_sched.htm#CIHHBGGI

  • Oracle Job in Oracle 10g

    Hi,
    create or replace procedure insert_sch is
    begin
    insert into sudhir name values ('sudhir');
    end insert_sch;
    I have created a Stored Procedure. I need to create a job to run this every 1min, Please suggest me how to create Oracle jobs in 10g and 11i.
    Thanks
    Sudhir

    Hi
    Thanks have found the solution
    declare
    v_JobNo number := 123;
    begin
    dbms_job.submit(v_JobNo, 'insert_sch;', INTERVAL => 'SYSDATE+(1/24/60)');
    end;
    Thanks
    Sudhir

  • Backing up Jobs, Chains and Programs in Oracle Job Scheduler

    What is the best way to back up Jobs, Chains and Programs created in the Oracle Job Scheduler via Enterprise Manager - and also the best way to get them from one database to another. I am creating quite a long chain which executes many programs in our test database and wish to back everything up along the way. I will also then need to migrate to the production database.
    Thanks for any advice,
    Susan

    Hi Susan,
    Unfortunately there are not too many options.
    To backup a job you can use dbms_scheduler.copy_job. I believe EM has a button called "create like" for jobs and programs but I am not sure about chains and this can be used to create backups as well.
    A more general purpose solution which should also cover chains is to do a schema-level export using expdp i.e. a dump of an entire schema.
    e.g.
    SQL> create directory dumpdir as '/tmp';
    SQL> grant all on directory dumpdir to public;
    # expdp scott/tiger DUMPFILE=scott_backup.dmp directory=dumpdir
    You can then import into a SQL text file e.g.
    # impdp scott/tiger DIRECTORY=dumpdir DUMPFILE=scott_backup SQLFILE=scott_backup.out
    or import into another database (and even another schema) e.g.
    # impdp scott/tiger DIRECTORY=dumpdir DUMPFILE=scott_backup
    Hope this helps,
    Ravi.

  • Oracle Job in progress for too long (3 days)

    Hi guys,
    i am using oracle 10.2.0.3 database. One of the oracle job is in progress for almost 3 days & in active state.
    i tried enabling trace but didnt get anything. please let me know what should i do. EM also dont show any current or previous SQL & the wait event is "jobq slave wait" ....
    please help.....

    Here is the current situation i can see at OEM.
    Current Status ACTIVE
    Serial Number 4285
    DB User Name JOBS
    OS Process ID 6492
    Logged On Since May 29, 2009 1:12:33 PM
    Logged On For 3 Days, 22 Hours, 49 Minutes, 3 Seconds
    Connection Type DEDICATED
    Type USER
    Resource Consumer Group Unavailable
    Client
    OS User Name admin
    OS Process ID 6492
    Host ORACLE_PRODUCTION
    Terminal ORACLE_PRODUCTION
    Current Client ID Unavailable
    Current Client Info Unavailable
    Application
    Current SQL None
    Current SQL Command UNKNOWN
    Previous SQL None
    Last Call Elapsed Time 3 Days, 22 Hours, 49 Minutes, 2 Seconds
    SQL Trace DISABLED
    Open Cursors 7
    Program ORACLE.EXE (J000)
    Service SYS$USERS
    Current Module Unavailable
    Current Action Unavailable
    Contention
    Blocking Session ID None
    Wait
    Current Wait Event jobq slave wait
    Current Wait Class Idle
    Waiting for 2 Minutes, 11 Seconds
    P1 None
    P2 None
    P3 None
    Object None

  • Oracle 11g - Non Oracle JOB ?

    Oracle 11g - Non Oracle JOB ?
    =====================
    I hope this is the right forum for this issue, if not let me, where to go.
    We are using Oracle 11g (11.2.0.1.0) on (Platform : solaris[tm] oe (64-bit)), Sql Developer 3.0.04
    1) We are loading table using PL/SQL -- > at Oracle server.
    2) This data is consumed by Mainframe DB2 process -- > at DB2 server.
    3) Return us another table with derived data from DB2 -- > at DB2 server.
    There is a IBM JCL read our table and return a Oracle table with calculated data.
    Do we able to automate a process using PL/SQL to start the IBM JCL upon loading the table Step (1)?
    Are there any alternate approach?
    Thanks in helping us.
    Edited by: qwe16235 on Jul 19, 2011 1:54 PM

    Hello,
    I read the DBMS_SCHEDULER pieces. We need to create a job (Pl/sql procedure or shell script) to configure the DBMS_SCHEDULER.
    If we are going to do such thing in the server, where our current Oracle DB instance located, we can perform desired tasks via jobs. No issues.
    I reviewed the components within DBMS_SCHEDULER to start job on another server, where there is no Oracle DB instance running. I did not find any clue/pointer on the referred doc.
    Do we need any additional components to do such things?
    We are on Server A with Oracle DB 11g and Server B with Non-Oracle and no Oracle Instance running there.
    How do we create a Job J1 on Server A, where it will request Server B to start a Job J2 in Non-Oracle instance?
    Do we have a component within DBMS_Scheduler to do that?
    Thanks in helping.

  • Help, How to view the error log of oracle Job

    Hi all,
    I created a job in my database, which clears the archivelog. After the job is executed, it occurs error.Such as :
    RMAN清理归档日志 1 问题 2010-3-19 下午03时11分00秒 GMT+08:00 PTDB 数据库实例 SYSTEM RMAN 脚本
    How to view the error log of oracle Job?
    Thank you.
    Eric Zhou

    Hello,
    Besides some views (with the scheduler) that you can get on the link below:
    http://download-west.oracle.com/docs/cd/B28359_01/server.111/b28310/scheduse002.htm#CHDGIDFD
    You may use the LOG parameter with RMAN so as to generate a logfile on the server.
    Also from EM DBConsole (starting with 10g) you may have the RMAN Backup Report.
    Hope this help.
    Best regards,
    Jean-Valentin

  • Window oracle job scheduler and Oracle server scheduler relationship

    Hi Experts,
    We use oracle 10G R4 in window 2003 server.
    From window server panel,we can see OracleJobSchedulerORCAID server is disable. However, I check oracle Jobs from EM.
    I can saw schedule jobs are running in there.
    What relationship is between window scheduler server and Oracle Schdeler?
    As I know we can stop/start window Oracle database serve,r DBconsle EM server and Listener server in window server to control oracle
    .Why window oracle schedule does not affect Oracle schdule job?
    Thanks Experts to explaining?
    JIm

    10g R4 is not an existing Oracle version. 10.2.0.4 is.
    Oracle EM has three different schedulers:
    - dbms_job
    - dbms_scheduler
    - EM's own scheduler. Jobs submitted in the EM scheduler are spawned by the Management Agent.
    Sybrand Bakker
    Senior Oracle DBA

  • Start external application with oracle job

    I'm trying to start external program with oracle job.
    Here is an example (I used SYS as SYSDBA):
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'my_job',
    job_type => 'executable',
    job_action => 'C:/WINDOWS/system32/cmd.exe',
    enabled => true,
    auto_drop => false );
    END;
    But job STATE comes FAILED.
    How should I do this?
    Result was not better when I used
    BEGIN
    DBMS_SCHEDULER.CREATE_PROGRAM (
    program_name => 'my_prg',
    program_type => 'EXECUTABLE',
    program_action => 'C:/WINDOWS/system32/cmd.exe',
    enabled=>TRUE);
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'my_job',
    program_name => 'my_prg',
    enabled => TRUE,
    auto_drop => false );
    END;
    Edited by: user458393 on Feb 16, 2010 1:55 AM

    Take a look at this thread: Running a Windows BAT file using DBMS_SCHEDULER
    C.

  • How to exclude create oracle job when during oracle imp

    Hi Expert,
    I would like to know how to exclude create oracle job during oracle import . It is schema export. Tks
    Regard
    Liang

    Oracle attempts to reimport job definitions as well. However, if you have an existing job with the same JOB_ID, the job definition fails (as there is a Unique Constraint on it).
    So, one "workaround" is to precreate dummy jobs before the import (which also means that the database account must be created in advance). To ensure that the JOB_ID is the same, you may have to keep incrementing the JOB_ID sequence.
    Hemant K Chitale

  • What Are the Current Oracle Job Market Trends?

    What Are the Current Oracle Job Market Trends?
    * what skills are becoming more and more useful and what database components are getting idle?
    * Is Oracle DBA job market over-supply?

    That remind me a discussion we have had few months ago...
    Re: It is a mistake to set foot in DBA career
    Nicolas.

  • Missing AW Maintenance Details When Submitting to Oracle Job Queue

    Is there a way to know the number of added/deleted members or the processed/ rejected records of a dimension/cube maintenance that was submitted to the Oracle Job Queue?
    The following is the log of my recent maintenance task that was submitted to the Oracle Job Queue:
    18:59:03 Attached AW OLAP_TEST.AW_TEST in RW Mode.     
    18:58:27 Completed Build(Refresh) of OLAP_TEST.AW_TEST Analytic Workspace.     
    18:58:27 Finished Parallel Processing.     
    18:58:21 Running Jobs: AWXML$_2534_1. Waiting for Tasks to Finish...     
    18:58:21 Started 1 Finished 0 out of 1 Tasks.     
    18:58:21 Running Jobs: AWXML$_2534_1.          Usually, there would be a line in the XML_LOAD_LOG table where the added/deleted members or processed/rejected records can be found. In this case, there is none.

    Usually the entries you want are before these lines (time-wise). The parallel processing only handles aggregating fact partitions in parallel, not loading the base level data.

  • Oracle jobs in India

    I am from India and 11g OCP.Please suggest me where can I get an Oracle DBA job Delhi or Bangalore or Hyderabad.Which city is best to go for Oracle job?

    This is not the right place for such request, thread locked.
    Nicolas.

Maybe you are looking for