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 9004917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:00:40+00:00 2026-06-16T01:00:40+00:00

i came across a problem on PLSQL and hope i can get here some

  • 0

i came across a problem on PLSQL and hope i can get here some help .
i have 2 tables – the first is called test1, and has 2 columns – customer_id and msisdn and has 2 records in it.
the other one is called test_hist and has 3 columns – customer_id, msisdn and seqno and have 1 record.
“seqno” is a sequnce number. every record that’s inseted get a seqno number which is higher by 1.
the script i wrote is :

DECLARE

CURSOR test IS
SELECT * FROM test1; 


CUSTOMER_ID NUMBER;
MSISDN NUMBER;
V_SEQNO NUMBER;

BEGIN

    FOR a IN test LOOP

        SELECT MAX(SEQNO)+1 INTO V_SEQNO FROM test1_hist;

        INSERT INTO test1_hist
        select a.CUSTOMER_ID ,v_seqno, a.msisdn
        from test1;
    END LOOP;
    commit;

END;

the problem is, that after running it, this is what i get on test_hist table :

CUSTOMER_ID SEQNO   MSISDN

1.55443322  3   5422112
1.55443322  3   5422112
1.12232323  2   5454554
1.12232323  2   5454554
1.22211444  1   544643330

it runs the same times as the number of records.
if i had 4 records on test1 table, it would insert to test_hist 16 (4 of each)in total.
the original table im working with has 400k records, so i cant just do few simple insert statements…. (:
im using TOAD , the environement is ORACLE 8.

any idea what am i missing ?

thanks very much
Assaf.

  • 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-16T01:00:41+00:00Added an answer on June 16, 2026 at 1:00 am

    you could use sequence ..then there is no need for pl/sql block to insert the data..can be done in simple insert…other wise use pl/sql with dual or values

    DECLARE

    CURSOR test IS
    SELECT * FROM test1;

    CUSTOMER_ID NUMBER;
    MSISDN NUMBER;
    V_SEQNO NUMBER;
    BEGIN
    
        FOR a IN test LOOP
    
            SELECT MAX(SEQNO)+1 INTO V_SEQNO FROM test1_hist;
    
            INSERT INTO test1_hist
            select a.CUSTOMER_ID ,v_seqno, a.msisdn
            from dual;
        END LOOP;
        commit;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing some exercises and I came across a problem. I have got DLL
I came across such problem: I wanted to have some Fragment as public static
I came across a problem and can not move forward because I cannot get
I have came across this problem a few times and can't seem to figure
Came across a problem which google searches could not help me with. I have
I came across one problem. I've created some tabs functionality as can be seen
Guys, I've came across this problem I can't resolve myselg, I'm pretty sure I
I came across a problem that seems to be called drowning in autorelease pools.
I recently came across a problem for image file storage in network. I have
I'm starting with node expressjs framework and I came across this problem I can't

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.