Sign Up

Sign Up to our social questions and Answers Engine 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 Engine 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

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8688995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:31:23+00:00 2026-06-12T23:31:23+00:00

I wanted to export 3 tables from db1 into db2. Before the export starts,

  • 0

I wanted to export 3 tables from db1 into db2.

Before the export starts, I will create the sequences for those 3 tables.

CREATE SEQUENCE TEST_SEQ START WITH 1 INCREMENT BY 1;

After the export, I will reinitialize sequnce values to match the max(id) + 1 from the table.

CREATE OR REPLACE PROCEDURE "TEST_SEQUENCE"
AUTHID CURRENT_USER
is
v_num number;
begin
select max(ID)  into v_num from TABLE_1;
EXECUTE IMMEDIATE 'ALTER SEQUENCE TEST_SEQ  INCREMENT BY ' || v_num;
EXECUTE IMMEDIATE 'ALTER SEQUENCE 1TEST_SEQ  INCREMENT BY 1'; 
end;
/
show errors;
execute TEST_SEQ;

This procedure compiles and executes without problems.

But when I want to check t he last value of the sequence, like
select TEST_SEQ.nextval from dual;

I still get the “1”.

Can someone tell me why my procedure did not impact my sequence?
ps. I am using oracle sql developper to pass sql.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:31:25+00:00Added an answer on June 12, 2026 at 11:31 pm

    You need to actually make the sequence increment between the two alter statements:

    EXECUTE IMMEDIATE 'ALTER SEQUENCE TEST_SEQ  INCREMENT BY ' || v_num;
    select test_seq.nextval into v_num from dual;
    EXECUTE IMMEDIATE 'ALTER SEQUENCE TEST_SEQ  INCREMENT BY 1'; 
    

    In 11g you can assign the sequence directly:

    v_num := test_seq.nextval;
    

    Either way you don’t need to do anything with that value, you just need to generate it.

    Alternatively you could create the sequences after the load, and set the starting value based on what you just loaded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to export a lot of large tables from a MS Access
We are using an extractor application that will export data from the database to
I wanted to export the results of a certain query into a file and
I wanted to export a simple function from a base class that I use
Say I wanted to write a program that would export calendar data so that
I just learnt XSLT today when I wanted to pretty print the playlist export
Wanted to know if there was a way one could query shelveset details from
just wanted to ask where I define initial class properties? From other languages I
I have a table of data and i wanted an export function, this application
I wanted to export my local datastore data to my google appengine application datastore.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

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.