Oracle Sequence Statement Reset Party introduction _oracle

Source: Internet
Author: User
In the development process, may use the Oracle sequence statement, this article takes the Oracle sequence statement how resets carries on the introduction, needs the friend to be possible to refer to under
Oracle Reset sequence Statement 1
SQL code
Copy Code code as follows:

DECLARE
N Number (10);
TSQL VARCHAR2 (100);
P_seqname varchar2 (20);
BEGIN
P_seqname: = ' seq_run_id ';
EXECUTE IMMEDIATE ' SELECT ' | | P_seqname | | '. Nextval from dual ' into N;
N: =-(n-1);
TSQL: = ' alter sequence ' | | P_seqname | | ' Increment by ' | | N
EXECUTE IMMEDIATE TSQL;
EXECUTE IMMEDIATE ' SELECT ' | | P_seqname | | '. Nextval from dual ' into N;
TSQL: = ' alter sequence ' | | P_seqname | | ' increment by 1 ';
EXECUTE IMMEDIATE TSQL;
EXCEPTION
When others THEN
Dbms_output.put_line (SQLERRM);
End;

Oracle Reset sequence Statement 2
SQL code
Copy Code code as follows:

CREATE OR REPLACE PROCEDURE reset_sequence (p_sseqname in VARCHAR2)
Is
N Number (10);
TSQL VARCHAR2 (100);
BEGIN
EXECUTE IMMEDIATE ' SELECT ' | | P_sseqname | | '. Nextval from dual '
into N;
N: =-(n-1);
TSQL: = ' alter sequence ' | | P_sseqname | | ' Increment by ' | | N
EXECUTE IMMEDIATE TSQL;
EXECUTE IMMEDIATE ' SELECT ' | | P_sseqname | | '. Nextval from dual '
into N;
TSQL: = ' alter sequence ' | | P_sseqname | | ' Increment by 1 ';
EXECUTE IMMEDIATE TSQL;
EXCEPTION when others THEN
NULL;
End Reset_sequence;

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.