Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Time Activated Functions In SQL

  • 03-04-2006 10:41AM
    #1
    Registered Users, Registered Users 2 Posts: 871 ✭✭✭


    I was just wondering if it is possible to create a PL/SQL function that is time activated, eg called at midnight?


Comments

  • Moderators, Politics Moderators, Paid Member Posts: 44,042 Mod ✭✭✭✭Seth Brundle


    You mean a stored procedure.
    What version of Oracle?
    What OS?
    You can do this inside the enterprise manager (or via a script)

    Also read
    http://www.geekinterview.com/question_details/16884
    http://sybernet.sri.com/sybase/procedures/SP_HTML_CRON_REGISTER.html


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    time activated functions

    I believe they're more commonly called Jobs ;)

    DBMS_JOB is most-likely what you're looking to play with here. One tip: Make sure job_queue_processes / job_queue_interval are set up in init.ora. These parameters are version dependant (interval is for 8 & 8i only, IIRC).

    You could use OS-dependant scheduling systems like cron in *nix, but DBMS_JOB avoids many potential issues that external schedulers can run into.

    jc


  • Registered Users, Registered Users 2 Posts: 871 ✭✭✭gerTheGreat


    OK, so i've gotten this far. I've created this function, but it's apparently containing an error, can anyone see the problem?

    CREATE OR REPLACE FUNCTION AGE (BIRTH_DATE in DATE)
    RETURN NUMBER IS
    AGE NUMBER;
    BEGIN
    AGE := TRUNC(MOUNTHS_BETWEEN(SYSDATE, BIRTH_DATE)/12.0);
    RETURN AGE;
    END;


    (P.S. thanks kbannon and bonkey, I'm not totally sure if i have the admin access to do that but I'll give it a shot once I get the function working)


  • Moderators, Politics Moderators, Paid Member Posts: 44,042 Mod ✭✭✭✭Seth Brundle


    Im kind of surprised that you are running a function at a certain time. Where is the returned value going?

    edit: I presume you haven't compiled that finction yet given the typos in it.


Advertisement