Oracle stored procedure and Timer

Source: Internet
Author: User

Yan Bin (write to me)
Original blog (http://blog.csdn.net/binbinxyz), reprint please indicate the source!

Assume that a five-digit number is obtained from the database as the serial number of the business on the current day (unique on the current day)

So we designed a table to store the current number:

Create Table tbl_trade_sn_inf (Sn number default 99999)

Add the Stored Procedure pro_trade_sn_init to initialize the SN:

Create or replace procedure pro_trade_sn_init isbegin update tbl_trade_sn_inf Set Sn = 99999; end pro_trade_sn_init;

Add the timer job_trade_sn to call the stored procedure every day to initialize the SN number:

Begin dbms_job.submit (: job_trade_sn, 'Pro _ trade_sn_init; ', sysdate, 'trunc (sysdate + 1) + 1000'); -- run end at one o'clock every day;/

Start the Timer:

Begin dbms_job.run (: job_trade_sn); end ;/

In this way, the number is automatically initialized every morning.

Important:This article is purely intended to record the stored procedure and timer usage. If there are other improper designs, do not compare them!

Yan Bin (write to me)
Original blog (http://blog.csdn.net/binbinxyz), reprint please indicate the source!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.