Sign Up

Sign Up to our social questions and Answers to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In


Have an account? Sign In Now

Sign In

Login to our social questions & Answers to ask questions, answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Sorry, you do not have permission to add post.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Oraask Logo Oraask Logo
Sign InSign Up

Oraask

  • Write
    • Add A New Post
    • Ask A Question

Oraask Navigation

Search
Ask A Question

Mobile menu

Close
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
Home/ Questions/Q 21842
Next

Oraask Latest Questions

Question
Waqas
  • 0
  • 0
WaqasExplorer
Asked: August 12, 20172017-08-12T19:47:26+03:00 2017-08-12T19:47:26+03:00In: Oracle SQL

Why is Sequence not incrementing ?

  • 0
  • 0

Hi,
Oracle : 9.2.0.8.0

We have sequence as below:

[code]
CREATE SEQUENCE TEST_SEQ
START WITH 41554558016
INCREMENT BY 2
MAXVALUE 1000000000000000000000000000
MINVALUE 1
NOCYCLE
CACHE 40
NOORDER;
[/code]

We have written a procedure to increment the sequence value based on another sequence value by comparing the two values.

But when I execute the procedure the sequence is not getting incremented as expected.

Can some one help if I am missing out something here?

Below is the procedure. We always pass p_pk_src_max_value < p_pk_dest_max_value

[code]
CREATE OR REPLACE PROCEDURE test_seq_reset_src(p_pk_src_max_value NUMBER,
p_pk_dest_max_value NUMBER) AS

l_delta_value number := 0;
l_max_value number := 0;
BEGIN
dbms_output.put_line(‘Max sequence number in src:’||p_pk_src_max_value);
dbms__output.put_line(‘Max sequence number in dest:’||p_pk_dest_max_value);

IF p_pk_src_max_value > p_pk_dest_max_value THEN
–l_delta_value := p_pk_src_max_value – p_pk_dest_max_value ;
dbms_output.put_line(‘If src max value greater then delta value:’||l_delta_value);
–l_max_value := p_pk_src_max_value;
ELSE
BEGIN
l_delta_value := p_pk_dest_max_value – p_pk_src_max_value ;
dbms_output.put_line(‘If dest max value greater then delta value:’||l_delta_value);
l_max_value := p_pk_dest_max_value;
IF MOD(l_max_value, 2)= 0 THEN
dbms_output.put_line(‘src MAX value is EVEN and starting new sequence value :’ || l_max_value);
ELSE
dbms_output.put_line(‘src MAX value is ODD and starting sequence value :’ || l_max_value);
l_delta_value := l_delta_value + 1;
END IF;

EXECUTE IMMEDIATE ‘ALTER SEQUENCE TEST_SEQ INCREMENT BY ‘|| l_delta_value;
dbms_output.put_line(‘TEST_SEQ increment by delta value:’||l_delta_value);
EXECUTE IMMEDIATE ‘select TEST_SEQ.nextval from dual’; /*!!! Replace this line !!!*/
EXECUTE IMMEDIATE ‘ALTER SEQUENCE TEST_SEQ INCREMENT BY 2’;
END;
END IF;
END TEST_SEQ_RESET_src;
[/code]

execute immediateincrementingproceduresequencesql
0
  • 0 0 Answers
  • 470 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    Related Questions

    • How to get Column Names from a Table in Oracle
    • What are the different types of case manipulation functions available in Oracle SQL
    • What is the use of ADD, DROP and MODIFY Commands
    • What are the differences between SQL and PL/SQL in Oracle
    • What is the use of LIMIT and OFFSET in SQL

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    Sidebar

    Adv 250x250

    Explore

    • Categories
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Dev Tools
      • Online Compiler
      • Base64 Converter
    • Wiki
      • SQL Tutorials
      • Java Tutorials
      • Python Tutorials
      • JavaScript Tutorials

    Footer

    Oraask

    About

    Oraask is a website for developers and software engineers who want to learn new skills, share their knowledge, and solve their coding problems. Oraask provides free content on various programming languages and topics, such as Oracle, Python, Java, etc. Oraask also allows users to ask questions and get answers from other members of the community.

    About Us

    • About Us
    • Contact Us

    Legal Stuff

    • Privacy Policy
    • Terms & Conditions

    Follow

    Oraask is licensed under CC BY-NC-SA 4.0Oraask CopyrightOraask CopyrightOraask CopyrightOraask Copyright

    © 2019 Oraask. All Rights Reserved
    With Love by Oraask.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.