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!