1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Oracle - How to write simple PL/SQL procedure

Discussion in 'SQL PL/SQL' started by rcbandit, Dec 18, 2011.

  1. rcbandit

    rcbandit Guest

    Hi,
    I have a simple PL/SQL block. Can you tell me are there any mistakes. I don't have running Oracle installation to test it.

    Code (Text):

    BEGIN
    sys.dbms_scheduler.create_job(
    job_name => '"ADMIN"."USERSESSIONFLUSH"',
    job_type => 'PLSQL_BLOCK',
    job_action => 'begin
       -- Insert PL/SQL code here
       delete from UserSessions where last_login < sysdate - 30/1440;
    end;',
    repeat_interval => 'FREQ=MINUTELY;INTERVAL=2',
    start_date => systimestamp at time zone 'Asia/Nicosia',
    job_class => '"DEFAULT_JOB_CLASS"',
    comments => 'Flushes expired user sessions',
    auto_drop => FALSE,
    enabled => FALSE);
    sys.dbms_scheduler.set_attribute( name => '"ADMIN"."USERSESSIONFLUSH"', attribute => 'job_priority', value => 5);
    sys.dbms_scheduler.set_attribute( name => '"ADMIN"."USERSESSIONFLUSH"', attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_FAILED_RUNS);
    sys.dbms_scheduler.enable( '"ADMIN"."USERSESSIONFLUSH"' );
    END;

     
    Regards
    Peter
     
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,351
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Looks good to me.
     
  3. kiran.marla

    kiran.marla Forum Genius

    Messages:
    403
    Likes Received:
    52
    Trophy Points:
    505
    Location:
    Khammam
    What do you exactly looking for ?
    Running the script ??
    or Output ???