DBMS_schedular.create_job procedure

HI ,
I am trying write a scheduler for one of the Pl/SQL package...
Here is the package i m trying to schedule...This works absolutely fine
  --- Spec
create or replace package my_pack
as
begin
procedure common_proc(var_num number);
end;
  --- Body
create or replace package body my_pack
as
  procedure insert_tbl1(v_num number)
   is
    begin
       insert into tbl1 values (....)
          select ....from src_tbl where col1 = v_num and ...and...;
   end;
   procedure insert_tbl2(v_num number)
    is
    begin
       insert into tbl2 values (....)
          select ....from src_tb1 where col1 = v_num and ...and...;
   end;      
   procedure insert_tbl3(v_num number)
    is
    begin
       insert into tbl3 values (....)
          select ....from src_tb1 where col1 = v_num  and ...and...;
   end;
   procedure insert_tbl4(v_num number)
    is
    begin
       insert into tbl4 values (....)
          select ....from src_tb1 where col1 = v_num  and ...and...;
   end;  
  procedure common_proc(var_num number )
  as
   begin
        insert_tbl1(var_num);
        insert_tbl2(var_num);
        insert_tbl3(var_num);
        insert_tbl4(var_num);
   end;            
end my_pack;
Here is the procedure for scheduling the above package...
  create or replace procedure  schedule(s_num in number )
     as
   var_1 varchar2; -- sqlstr
   var_2 varchar2;  -- v_jobn
   begin
     var_1 := 'my_pack.common_proc('''||s_num||''');';
     dbms_output.put_line(var_1);
     var_2 := 'my_pack_'||to_char(s_num);
     dbms_output.put_line('job name :'||var_2);
     dbms_schedular.create_job(
                                   job_name => var_2
                                  ,job_type => 'PLSQL_BLOCK'
                                  ,job_action => 'begin '||var_1||' end; '
                                  ,start_date => NULL
                                  ,repeat_interval => NULL
                                  ,enabled => TRUE
                                  ,comments => null
                                  ,auto_drop => TRUE 
   exception
     when others then
     raise;
   end schedule;
When i compile the above schedule procedure, i get the following error
   PLS-00201: identifier 'DBMS_SCHEDULER' must be declared
ANy idea why ???Next question,
- how would i test this scheduler?? do i need to run the procedure with passing the parameter or how would i know whether schedular is kicked off or running or any place i can i see the logs ???
- If you have any idea of making this procedure schedule to write in a efficient way, please feel free to suggest me
last thing, i m tottally new to schedular, this is the first time i m using it..
Your suggestions or advice or help is greatly appriciated!!!
thank you so much !!!

I think you are missing the privileges.
GRANT CREATE JOB,MANAGE SCHEDULER to <user>;
They have explained scheduler here : http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm#i1000363
Since you are setting the start_date to null, the job will be executed as soon as it gets created.
You can check the status of the run by:
SELECT * FROM USER_SCHEDULER_JOB_RUN_DETAILS
WHERE job_name = <>
ORDER BY log_Date DESC;
You can see the running jobs by:
select job_name
, session_id
, running_instance
, elapsed_time
, cpu_used
from USER_SCHEDULER_RUNNING_JOBS;
Note that there are "DBA" counterparts of these tables too.

Similar Messages

  • DBMS_SCHEDULER.create_job Procedure will not fire

    I have created a procedure that does not seem to want to run
    create or replace
    procedure sched is
    BEGIN
      DBMS_SCHEDULER.create_job
        job_name        => 'my.MAILER',
        job_type        => 'PLSQL_BLOCK',
        job_action      => 'BEGIN MAILER;  END;',
        start_date      => SYSTIMESTAMP,
        repeat_interval => 'freq=daily;',
        end_date        => null,
        enabled         =>  TRUE,
        comments        => 'Fire off the my.MAILER procedure'
    END sched;Compiled the procedure and then ran it.
    then ran
    SELECT *
    FROM ALL_SCHEDULER_JOBS;and nothing..
    Any advice ?
    Edited by: Slider2015 on Mar 13, 2012 4:08 PM

    Hi,
    Using 'my.MAILER' puts the job in the schema 'my' . Is this what you intended to do ?
    If there are no errors after running this (you are also missing a "/" at the end which runs it) then the job will show up in dba_scheduler_jobs .
    -Ravi

  • "can not start a job" issue in AWM

    Hi ALL,
    I am maintaining my cube from PLSQL with following options
    1. buildtype = "BACKGROUND"
    2. trackstatus = "true"
    3. maxjobqueues = 3
    i get following error when i see the "olapsys.xml_load_log" table
    ***Error Occured: Failed to Build(Refresh) DB_OWNER.MY_ANALYTICAL_WORKSPACE Analytic Workspace. Can not start a job.
    Can anybody explain when and why this error occurs? I have wasted a lot of time searching for this issue, but have found no person facing such issue.
    Hi Keith, it will be great if you can answer this one.
    My database version is 10.2.0.4.0 and AWM version is also 10.2.0.3.0
    Kind Regards,
    QQ
    Message was edited by:
    dwh_10g

    Applies to:
    Oracle OLAP - Version: 10.1 to 11.1
    This problem can occur on any platform.
    Symptoms
    - We have an AW maintenance / refresh script or procedure that contains BuildType="BACKGROUND", so that the AW maintenance task will be sent to the Oracle Job queue.
    - When we execute the AW maintenance / refresh script or procedure, we do not get any errors in the foreground, the script/procedure has been executed successfully.
    - However when we look into the build/refresh log (see <Note 351688.1> for details) we see that the maintenance/refresh task failed with:
    13:29:39 Failed to Submit a Job to Build(Refresh) Analytic Workspace <schema>.<AW Name>.
    13:29:39 ***Error Occured in BUILD_DRIVER
    - In the generated SQL trace for the session of the user who launches the AW build/refresh script or procedure, we see that ORA-27486 insufficient privileges error occurred at creation of the job.
    We see from the relevant bit of the SQL trace that err=27486 occured while executing the #20 statement which is 'begin DBMS_SCHEDULER.CREATE_JOB ...', and the statement is parsed and tried to be executed as user having uid=91:
    PARSING IN CURSOR #20 len=118 dep=2 uid=91 oct=47 lid=91 tim=1176987702199571
    hv=1976722458 ad='76dd8bcc'
    begin
    DBMS_SCHEDULER.CREATE_JOB(:1, 'plsql_block', :2, 0, null, null, null,
    'DEFAULT_JOB_CLASS', true, true, :3); end;
    END OF STMT
    PARSE
    #20:c=1000,e=1100,p=0,cr=0,cu=0,mis=1,r=0,dep=2,og=1,tim=1176987702199561
    EXEC #20:c=65990,e=125465,p=10,cr=1090,cu=3,mis=1,r=0,dep=2,og=1,tim=
    1176987702325167
    ERROR #20:err=27486 tim=465202984
    Cause
    User who tries to create a job (executes DBMS_SCHEDULER.CREATE_JOB() procedure) does not have the sufficient privileges.
    Solution
    1. Identify the user under which the job is supposed to be created. This user is not necessarily the same as the user who launched AW build/refresh script or procedure. Get the corresponding username from one of the %_USERS views e.g. from ALL_USERS.
    e.g.
    SELECT user_id,username FROM all_users WHERE user_id=91;
    2. Identify the system privileges currently assigned to the user by connecting as the user whom the privileges need to be determined, and execute:
    SELECT * FROM SESSION_PRIVS ORDER BY PRIVILEGE;
    3. Ensure that the CREATE JOB privilege is listed.
    The CREATE JOB privilege can be granted in various ways to a user:
    - via role OLAP_USER or via role OLAP_DBA (see view ROLE_SYS_PRIVS for what privs are assigned to a role):
    GRANT OLAP_USER TO <username>;
    - explicitly
    GRANT CREATE JOB TO <username>;

  • DBMS SCHEDULER: Job of type 'Chain' is failing

    Hi,
    I am using Oracle 10gR2 version. The job created on top of chain is failing for some reason. I couldn't trace the exact error. Please help me in debugging this as I am new to using dbms scheduler.
    --Script I have used to create a chain
    BEGIN
    DBMS_SCHEDULER.create_chain (
    chain_name => 'DAILY_JOB_CHAIN',
    rule_set_name => NULL,
    evaluation_interval => interval '5' minute ,
    comments => 'Chain to run the daily jobs');
    END;
    --Script used to create a job and start it immediately.
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'daily_job_rerun',
    job_type => 'CHAIN',
    job_action => 'daily_job_chain',
    start_date => SYSTIMESTAMP,
    auto_drop => true,
    enabled => TRUE);
    END;
    Soon after I ran the create_job procedure, the job has started immediately but is failing immediately without starting the chain. I have checked the USER_SCHEDULER_JOB_LOG table for errors. This is what is stored in the table.
    LOG_ID JOB_NAME OPERATION STATUS ADDITIONAL_INFO
    144835 DAILY_JOB_RERUN CHAIN_RUN FAILED CHAIN_LOG_ID="144834"
    144834 DAILY_JOB_RERUN CHAIN_START RUNNING
    Please help.
    Edited by: user10626493 on Oct 22, 2009 11:45 PM

    Chain rule for one of the chain steps has been changed and hence the job failed. After correcting the chain rule, the job has started fine.

  • Running shell scripts from within oracle. A big task is forgotten

    Dear List,
    I have some shell shell scripts which do some tasks on the linux OS level.
    I am calling the Korn scripts using a java class, which in turn is being called from a PLSQL function.
    All but one of the 10 script works fine. This is the script which does the most work, and takes on average 40 minutes usually.
    Why does Oracle forget the running of the shell script? I wait in my PLSQL function for the return code, but it never comes. The scripts I have not written myself !
    I look forward to your reply on this matter.
    regards
    Ben

    Hi
    If you are using the Oracle database 10g, the new dbms_scheduler package allows you to run shell scripts. The dbms_scheduler.create_job procedure have one parameter called the job_action in which you specify the full path of the shell script.
    I hope this will help

  • Cube Maintaining

    All,
    I'm in the process of re-building an AW using Non Aggregated Exports. All the importing into the new AW is completed. So I'm now in the process of maintain the base cubes, to aggregate the data. During the dialog via AWM, I'm given the option to run in parallel, which I accept and run 8 wide. The first two partitions complete relatively quicky, but then every 10 mins in the XML_LOAD_LOG table I get the following message:
    13:10:26 Running Jobs: AWXML$_28702_31138, AWXML$_28702_31139, AWXML$_28702_31140, AWXML$_28702_31141, AWXML$_28702_31142, AWXML$_28702_31143, AWXML$_28702_31144, AWXML$_28702_31146. Waiting for Free Process...
    After a number of hours the process completes with a non descript Error message:
    03:15:14 ***Error Occured: Failed to Build(Refresh) PNRG4_AW.PNRG Analytic Workspace.
    I assume this is because the Free Process is never got (so to speak). The relational side of this database is very busy as we're mid batch run (run takes several days). The Unix box is not under any stress though (SWAP or CPU). So my questions is what resource may be lacking in order for this job to grab a "Free Process"?
    Nick.

    Parallel cube builds use the DBMS_SCHEDULER.CREATE_JOB procedure to process each partition. If you specify 5 parallel processes, say, then the code will call DBMS_SCHEDULER.CREATE_JOB 5 times to start the first 5 slave jobs and will then go into a waiting loop. During this loop it will repeatedly run the following select statement waiting for the slaves to finish.
    select job_name, status from all_scheduler_job_run_details where job_name like ...If a slave finishes, then it will immediately start the next one by calling DBMS_SCHEDULER.CREATE_JOB again.
    The "Waiting for Free Process..." message that you see in the load log is a 'heart beat' message to let you know that the master process is in this waiting loop. The message will be sent to the log every 10 minutes.
    So in your case the slave processes are still working on the current batch of partitions and the master process is waiting for them to complete. This is not in itself a sign of a problem since partitions frequently take longer than 10 minutes to process, but obviously they are taking longer than you expect. The load log should give you some idea of what the slave processes are doing.

  • How to run the job using DBMS_SCHEDULER

    How to run the job using DBMS_SCHEDULER
    pleas give some sample Iam very new to DBMS_SCHEDULER

    Hi
    DBMS_SCHEDULER
    In Oracle 10g the DBMS_JOB package is replaced by the DBMS_SCHEDULER package. The DBMS_JOB package is now depricated and in Oracle 10g it's only provided for backward compatibility. From Oracle 10g the DBMS_JOB package should not be used any more, because is could not exist in a future version of Oracle.
    With DBMS_SCHEDULER Oracle procedures and functions can be executed. Also binary and shell-scripts can be scheduled.
    Rights
    If you have DBA rights you can do all the scheduling. For administering job scheduling you need the privileges belonging to the SCHEDULER_ADMIN role. To create and run jobs in your own schedule you need the 'CREATE JOB' privilege.
    With DBMS_JOB you needed to set an initialization parameter to start a job coordinator background process. With Oracle 10g DBMS_SCHEDULER this is not needed any more.
    If you want to user resource plans and/or consumer groups you need to set a system parameter:
    ALTER SYSTEM SET RESOURCE_LIMIT = TRUE;
    Baisc Parts: Job
    A job instructs the scheduler to run a specific program at a specific time on a specific date.
    Programs
    A program contains the code (or reference to the code ) that needs to be run to accomplish a task. It also contains parameters that should be passed to the program at runtime. And it?s an independent object that can referenced by many jobs
    Schedules
    A schedule contains a start date, an optional end date, and repeat interval with these elements; an execution schedule can be calculated.
    Windows
    A window identifies a recurring block of time during which a specific resource plan should be enabled to govern resource allocation for the database.
    Job groups
    A job group is a logical method of classifying jobs with similar characteristics.
    Window groups
    A window groups is a logical method of grouping windows. They simplify the management of windows by allowing the members of the group to be manipulated as one object. Unlike job groups, window groups don?t set default characteristics for windows that belong to the group.
    Using Job Scheduler
    SQL> drop table emp;
    SQL> Create table emp (eno int, esal int);
    SQL > begin
    dbms_scheduler.create_job (
    job_name => 'test_abc',
    job_type => 'PLSQL_BLOCK',
    job_action => 'update emp set esal=esal*10 ;',
    start_date => SYSDATE,
    repeat_interval => 'FREQ=DAILY; INTERVAL=10',
    comments => 'Iam tesing scheduler');
    end;
    PL/SQL procedure successfully completed.
    Verification
    To verify that job was created, the DBA | ALL | USER_SCHEDULER_JOBS view can be queried.
    SQL> select job_name,enabled,run_count from user_scheduler_jobs;
    JOB_NAME ENABL RUN_COUNT
    TEST_abc FALSE 0
    Note :
    As you can see from the results, the job was indeed created, but is not enabled because the ENABLE attribute was not explicitly set in the CREATE_JOB procedure.
    Run your job
    SQL> begin
    2 dbms_scheduler.run_job('TEST_abc',TRUE);
    3* end;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> select job_name,enabled,run_count from user_scheduler_jobs;
    JOB_NAME ENABL RUN_COUNT
    TEST_ABC FALSE 0
    Copying Jobs
    SQL> begin
    2 dbms_scheduler.copy_job('TEST_ABC','NEW_TEST_ABC');
    3 END;
    4 /
    PL/SQL procedure successfully completed. Hope it will help you upto some level..!!
    Regards
    K

  • Role of dba_jobs

    Hi,
    For testing purpose, I have created a Job using dbms_scheduler package, I have invoked create_schedule, create_program and create_job procedures.
    It all works well.
    Now, in the real-time, in our database, when I query from dba_jobs, I could see many entries, it is not clear how they appear here, does it come
    from 'dbms_scheduler.create_job' or through some other thing.
    Can you please provide more details and share me the mechanics of dba_jobs view, when data comes and disappears from here, what is the significance of this?
    Thank you.

    DBA_JOBS view is showing jobs created by the old DBMS_JOB package.
    For viewing jobs created by the new DBMS_SCHEDULER package, you want to look in the DBA_SCHEDULER_JOBS view (and probably take a look at DBA_SCHEDULER_* views as well ;-) )

  • Running shell scripts from GUI

    I'm trying to run a simple shell script (bash or sh) from the GUI (just double click it).
    I've managed to run it by double clicking, BUT, it runs from my home directory (even if i add --noprofile or remove #!/bin/bash line completely).
    How can I keep the current directory, or at least get it as a variable?
    Thanks,

    Hi
    If you are using the Oracle database 10g, the new dbms_scheduler package allows you to run shell scripts. The dbms_scheduler.create_job procedure have one parameter called the job_action in which you specify the full path of the shell script.
    I hope this will help

  • Parameters for Shell Script running through DBMS_SCHEDULER as Executable

    Hi,
    I'm using Oracle 10.2.0.1 on Solaris.
    I have a shell script to run through DBMS_SCHEDULER.
    DBMS_SCHEDULER.CREATE_PROGRAM (
    program_name => 'PROGRAM_NAME',
    program_type => 'EXECUTABLE',
    program_action => '/home/oracle/test.sh',
    enabled => TRUE,
    comments => 'Test Shell Script'
    But how do I define the parameters for the shell script?
    Lets say if I run the shell script from the Unix promt I will enter as below:
    /home/oracle/test.sh PITS aed5 XYZ
    How do I define it in the DBMS_SCHEDULER.define_program_argument?
    Thanks,
    Shail

    When you create the program you define the number of parameters it will accept:
    DBMS_SCHEDULER.CREATE_PROGRAM (
    program_name => 'PROGRAM_NAME',
    program_type => 'EXECUTABLE',
    program_action => '/home/oracle/test.sh',
    enabled => TRUE,
    comments => 'Test Shell Script',
    number_of_arguments     => 3
    );then you define your job arguments and set default values. This is optional - but if you don't then you will have to define the values using the set_job_argument_value:
    -- defines the first argument
    DBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
       program_name   => 'PROGRAM_NAME',
       argument_position   => 1,
       argument_name           => 'arg1',
       argument_type           'CHAR',
       default_value          => 'PITS',
    );You can set the argument vaues using:
    DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
       job_name => 'JOB1',   
       argument_position  => 1,
       argument_value => 'PITS');or using the argument name defined using the define_program argument
    DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
       job_name => 'JOB1',   
       argument_name  => 'arg1',
       argument_value => 'PITS');where JOB1 is a job for program PROGRAM_NAME created using the dbms_scheduler.create_job procedure
    see docmentation: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm for more details...

  • DBMS_SCHEDULER after insert row

    Hi,
    I have probably simple question..
    Is there any trick to run job after insert row?? I try to find some example, but all have repeat_interval :/ Thanks for all sugestions :)

    Why can't you use trigger? Or if it must be a job you can probably run job from trigger. By the way - repeat_interval is not the time when job is starting but the time between job executions. The time when job is starting can be set by start_date parameter of DBMS_SCHEDULER.CREATE_JOB procedure.

  • Testing the DBMS packages

    Hello,
    I m tottaly new to dbms schedulers and inbuilt packages. I have never used. I m trying make use of
    - DBMS_stats.gather_table_stats
    - DBMS_schedular.generate_job_name
    - DBMS_schedular.create_jobI was wondering, is there any i run these packages or test these packages just for learning purpose....
    And also it will be great, if you could briefly explain these in built packages....Thank you so much!!

    You can find demos in Morgans Library.
    http://www.morganslibrary.org/reference/dbms_scheduler.html
    http://www.morganslibrary.org/reference/dbms_stats.html
    As for the explanation, you should be able to find some decent detail by searching the documentation.
    http://www.oracle.com/pls/db112/homepage

  • How to use dbms_Scheduler.Create_Job from within stored procedure?

    Hello,
    using 10g (10.1.0.2.0) on Windows 2000 I had problems to create scheduler jobs from within a stored procedure (see example below). What easily succeeds using anonymous blocks failed when calling from a stored procedure, due to ORA-27486. Only when I compile the procedure with invoker's rights the call to dbms_Job.Create_Job is successfull!? From my knowledge there is no difference between invoker's and definer's rights, if I compile and call with the same user, is there?
    Does anyone know the reason for this behaviour or is it simply a bug?
    Have a nice day.
    Björn Hachmann
    Hamburg / Germany
    -- Example start.
    create table t
    a number(1),
    b date default sysdate
    create or replace procedure sched1
    is
    begin
    dbms_scheduler.create_job(
    job_name => 'TEST_JOB1',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN insert into t values (1); END;',
    repeat_interval => 'freq=secondly',
    enabled => TRUE
    commit;
    end;
    create or replace procedure sched2
    authid current_user
    is
    begin
    dbms_scheduler.create_job(
    job_name => 'TEST_JOB2',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN insert into t values (2); END;',
    repeat_interval => 'freq=secondly',
    enabled => TRUE
    commit;
    end;
    exec sched1; -- This call fails with ORA-27486.
    exec sched2; -- This call succeeds!
    /* Cleanup.
    exec dbms_scheduler.drop_job('TEST_JOB1', true);
    exec dbms_scheduler.drop_job('TEST_JOB2', true);
    drop table t;
    */

    Your example code ran without problems for me on 10.1.0.3.0 so it probably is a bug.

  • Calling SQL * LOADER  in stored procedure

    Hi Experts,
    Can we call sql*loader in stored procedures? . If yes , please let me know the syntax.
    Any help will be highly appreciated.
    Thanks.

    You can also use dbms_schedular to execute any shell or batch file - i guess ->
    BEGIN
      -- UNIX
      DBMS_SCHEDULER.create_job(
        job_name             => 'unix_command_job',
        job_type             => 'EXECUTABLE',
        number_of_arguments  => 1,
        job_action           => '/bin/ls',
        auto_drop            => FALSE,
        enabled              => FALSE);
      DBMS_SCHEDULER.set_job_argument_value('unix_command_job',1,'/tmp');
      DBMS_SCHEDULER.set_attribute('unix_command_job', 'credential_name', 'TIM_HALL_CREDENTIAL');
      DBMS_SCHEDULER.set_attribute('unix_command_job', 'destination', 'marge.localdomain:65001');
      DBMS_SCHEDULER.enable('unix_command_job');
    END;For details ->
    http://www.oracle-base.com/articles/11g/SchedulerEnhancements_11gR1.php
    http://www.oradev.com/dbms_scheduler.jsp
    http://www.psoug.org/reference/dbms_scheduler.html
    Regards.
    Satyaki De.

  • Cannot Send Email Notification Using Stored Procedure.

    Hi Friends,
    I tried to execute this job scheduler...
    begin
    dbms_scheduler.create_job(
    job_name => 'ILMS_JOB_SCHEDULE'
    ,job_type => 'PLSQL_BLOCK'
    ,job_action => 'begin ilms.check_reminder(); end; '
    ,start_date => SYSTIMESTAMP
    ,repeat_interval => 'FREQ=DAILY'
    ,enabled => TRUE
         ,end_date => NULL
    ,comments => 'Ilms job schedule for notification.');
    end;
    However, since the effect is too long I rescheduled the frequency to be every one minute in this set attribute...
    BEGIN
    DBMS_SCHEDULER.SET_ATTRIBUTE(
              name => 'ILMS_JOB_SCHEDULE'
              ,attribute => 'repeat_interval'
              ,value => 'FREQ=MINUTELY;INTERVAL=1'
    DBMS_SCHEDULER.DISABLE('ILMS_JOB_SCHEDULE');
    DBMS_SCHEDULER.ENABLE('ILMS_JOB_SCHEDULE');
    END;
    Check Reminder is the stored procedure invoked by job scheduler to check values in database columns before sending email notification to the respective recipients' email address and also the format of the email notification to be sent to the recipients...
    CREATE OR REPLACE PROCEDURE check_reminder AS
    NO number;
    CURSOR emp_cur is
    select * from pergerakan_ks where TASK_FLAG=7 and TASK_STATUS='InProgress';
    emp_rec emp_cur%rowtype;
    email_to varchar2(200);
    default_email varchar2(200);
    mesg varchar2(4000);
    no_kes varchar2(100);
    subj varchar2(4000);
    kpi number;
    crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );
    BEGIN
    default_email:='@abc.com.my';
    FOR emp_rec in emp_cur
    LOOP
    if emp_rec.PKS_TKH_TERIMA is null then
    dbms_output.put_line('count day ' || round(sysdate - to_date(emp_rec.pks_tkh_hantar)) || crlf || crlf);
    if round(sysdate - to_date(emp_rec.pks_tkh_hantar)) >3 then
    email_to:=emp_rec.pks_penghantar_id||default_email;
    select b.KS_BIL_NO into no_kes from kertas_siasatan b where b.KS_ID = emp_rec.pks_ks_id;
    subj:='Reminder untuk Membuat Tindakan Bagi No Kes '||no_kes;
    mesg:='Reminder untuk Membuat Tindakan Bagi No Kes '||no_kes;
    dbms_output.put_line('Sending email to ' || email_to || ' subject: ' || subj);
    dbms_output.put_line('update old pergerakan pks_id : '||emp_rec.pks_id);
    update pergerakan_ks set task_status='Done' where pks_id=emp_rec.pks_id;
    dbms_output.put_line('insert new pergerakan ks : ');
    insert into pergerakan_ks(pks_id,pks_ks_id,pks_km_id,pks_penghantar_id,pks_tkh_hantar,
    pks_penerima_id,pks_tkh_terima,task_name,task_owner,task_status,task_flag,fb_id)
    values(pks_id_seq.nextval,emp_rec.pks_ks_id,emp_rec.pks_km_id,
    emp_rec.pks_penghantar_id,sysdate,
    null,
    null,emp_rec.task_name,
    emp_rec.pks_penghantar_id,
    'InProgress',6,emp_rec.fb_id);
    commit;
    e_mail_message(email_to,email_to,subj,mesg);
    end if;
    end if;
    if emp_rec.PKS_TKH_TERIMA is not null then
    dbms_output.put_line('emp_rec.pks_km_id ' || emp_rec.pks_km_id || crlf);
    select c.KM_KPI into kpi from keluar_masuk_ks c where c.KM_ID = emp_rec.pks_km_id;
    no := round(sysdate - to_date(emp_rec.pks_tkh_terima))-kpi;
    dbms_output.put_line('count day - kpi' || no || crlf);
    dbms_output.put_line('kpi ' || kpi || crlf);
    if no = 1 then
    email_to:=emp_rec.pks_penghantar_id||default_email;
    select b.KS_BIL_NO into no_kes from kertas_siasatan b where b.KS_ID = emp_rec.pks_ks_id;
    subj:='Reminder untuk Membuat Tindakan Bagi No Kes '||no_kes;
    mesg:='Reminder untuk Membuat Tindakan Bagi No Kes '||no_kes;
    dbms_output.put_line('Sending email to ' || email_to || ' subject: ' || subj);
    email_to:=emp_rec.task_owner||default_email;
    subj:='Reminder untuk Membuat Tindakan Bagi No Kes '||no_kes;
    mesg:='Reminder untuk Membuat Tindakan Bagi No Kes '||no_kes;
    dbms_output.put_line('Sending email to ' || email_to || ' subject: ' || subj);
    e_mail_message(email_to,email_to,subj,mesg);
    e_mail_message(email_to,email_to,subj,mesg);
    end if;
    if no = 3 then
    select b.KS_BIL_NO into no_kes from kertas_siasatan b where b.KS_ID = emp_rec.pks_ks_id;
    email_to:=emp_rec.task_owner||default_email;
    subj:='Reminder untuk Membuat Tindakan Bagi No Kes '||no_kes;
    mesg:='Reminder untuk Membuat Tindakan Bagi No Kes '||no_kes;
    dbms_output.put_line('Sending email to ' || email_to || ' subject: ' || subj);
    e_mail_message(email_to,email_to,subj,mesg);
    end if;
    end if;
    END LOOP;
    END;
    E_mail_message is the stored procedure invoked by the check_reminder to tell scheduler information of the connection and the email address of the recipients...
    CREATE OR REPLACE procedure
    e_mail_message
    from_name in varchar2,
    to_name in varchar2,
    subject in varchar2,
    message in varchar2
    is
    l_mailhost VARCHAR2(64);
    l_from VARCHAR2(64);
    l_to VARCHAR2(64);
    crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );
    l_mail_conn UTL_SMTP.connection;
    mesg VARCHAR2( 4000 );
    BEGIN
    select a.SERVER into l_mailhost from email_setting a where a.SERVER is not null;
    select a.USERNAME into l_from from email_setting a where a.SERVER is not null;
    --UTL_SMTP.open_data(l_mail_conn);
    mesg:= 'Date: ' || TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss' ) || crlf ||
    'From: <'||l_from||'>' || crlf ||
    'Subject: ' ||subject|| crlf ||
    'To: '||to_name || crlf || '' || crlf ;
    mesg:=mesg||message;
    l_mail_conn := UTL_SMTP.open_connection(l_mailhost, 25);
    UTL_SMTP.helo(l_mail_conn, l_mailhost);
    UTL_SMTP.mail(l_mail_conn, l_from);
    UTL_SMTP.rcpt(l_mail_conn, to_name);
    UTL_SMTP.data(l_mail_conn, mesg);
    UTL_SMTP.quit(l_mail_conn);
    END;
    I tried to execute to execute the e_mail_message procedure but received this error. Also, no notification sent to the email address...
    ORA-29279: SMTP permanent error: 501 5.1.3 Invalid address
    ORA-06512: at "SYS.UTL_SMTP", line 21
    ORA-06512: at "SYS.UTL_SMTP", line 99
    ORA-06512: at "SYS.UTL_SMTP", line 241
    ORA-06512: at "ILMS.E_MAIL_MESSAGE", line 33
    ORA-06512: at line 13
    Please help so that I can receive the email notification into my email...thanks in advance for your time..

    user13281540 wrote:
    ORA-29279: SMTP permanent error: 501 5.1.3 Invalid address
    ORA-06512: at "SYS.UTL_SMTP", line 21
    ORA-06512: at "SYS.UTL_SMTP", line 99
    ORA-06512: at "SYS.UTL_SMTP", line 241
    ORA-06512: at "ILMS.E_MAIL_MESSAGE", line 33
    ORA-06512: at line 13This is not an Oracle error - this is the mail server saying "+hey, I don't like that e-mail address you are supplying, I'm not accepting it!+".
    If you look at RFC821 (Request For Comments memo 821 describes the SMTP specifications), you'll see that the sender and recipient needs to be supplied in the format +<[email protected]>+, e.g. +<[email protected]>+.
    I have found that not all SMTP servers are equal in this regard. Some may insist on the brackets around the address, some may not.
    You need to confirm the format of the addresses you use in the "+MAIL FROM+" and "+RCPT TO+" commands.. and ensure that these formats are accepted by your SMTP server - and if not, change your code to use an acceptable format.
    The easiest way to do this is using telnet - and interacting directly and manually with the server. SMTP is a clear text protocol and easy to use manually. Try it. It is the best way to test SMTP interaction and validate the approach and SMTP commands and arguments used by your code.

Maybe you are looking for

  • Need HELP to learn OAF development

    Hi, I am an experienced oracle financials developer. Most of my experience has been on using Developer 6i tools to develop front end and reports. Now I am planning to learn OAF framework to develop or to make customizations to the modules like iprocu

  • Work center in solution manager

    Hi, In the work center of solution manager, while trying to create job documentation : [https://websmp107.sap-ag.de/~sapidb/011000358700001975992008E/index.htm] from a change request the final step is to assign a logical component. When I click on th

  • Where can I buy a cooler for Satellite A300D-16Q?

    Where can I by a cooler for Satellite A300D-16Q?

  • Mail & Missing Plug-in /Java/

    I'm using MAIL Version 5.0 (1244.2/1244.3) and I have a situation. I would send digital poscards from iPhoto to my email and when I recieve it Mail wouldn't let me see it. It says "Missing Plug-in" but I have installed a proper plug-in - Java for Lio

  • Drag-drop stack bar in JGraph

    Hi, I have a stack graph created out of the database values. My requirement is to drag the graph bar and reposition it (the updated values should be saved in the DB). Could any one please help me in doing this. Please advice me on any logic to make t