The sequence starts from 0 every morning when the Oracle stored procedure is updated.

Source: Internet
Author: User

The sequence starts from 0 every morning during Oracle storage.

Create or replace procedure seq_reset
N NUMBER (10 );
Tsql VARCHAR2 (100 );
BEGIN
Execute immediate 'select SQD_LSH.nextval from dual'
INTO n;
N: =-(n );
Tsql: = 'alter sequence SQD_LSH increment by '| n;
Execute immediate tsql;
Execute immediate 'select SQD_LSH.nextval from dual'
INTO n;
Tsql: = 'alter sequence SQD_LSH increment by 1 ';
Execute immediate tsql;
 
END seq_reset;

First obtain the current value of sequence, and then set its step size to the opposite number of this value. Execute nextval to subtract the increasing part, so that the sequence returns to zero, and finally the recovery step size is 1.

Create a job and set it to run the stored procedure every day. See

Use JDBC to call Oracle stored procedures and functions in Java

Local compilation of Oracle stored procedures

Use of Oracle stored procedures and REF CURSOR

Solution to prompt "insufficient Permissions" during Oracle Storage

Oracle uses the stored procedure to return the result set development report

Tips for using temporary tables in Oracle stored procedures

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.