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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:07:33+00:00 2026-06-15T10:07:33+00:00

This is the situation: I have a table in an Oracle SQL DB. That

  • 0

This is the situation: I have a table in an Oracle SQL DB. That table is used for reporting purposes. It’s a test/development environement.
I want to test a new grouping feature in our report tools using this DB, but I have to update and replace all of the ‘numbers’ (not being the key for that table).
Several data sets can share the same ‘numbers’. The updated numbers should follow a certain pattern to be auto-testable. I thought of something like an integer that is increased for each a new number.
So here is waht I did so far:
At first I query all unique ‘numbers’ in that table, then I loop over the result table to replace each of ‘number’ found with the generated ‘new_number’. Then ‘new_number’ is increased by one before taking the next ‘number’ of the result table to be exchanged in the live table, and so on.

Here is the code:

DECLARE
    Cursor MyCursor IS
        SELECT DISTINCT NUMBER
            FROM TABLE
            ORDER BY NUMBER;

    entry MyCursor%ROWTYPE;
    new_number NUMBER := 111111;

    BEGIN
    FOR entry IN MyCursor LOOP
        IF MyCursor%FOUND THEN
            UPDATE TABLE
                SET
                NUMBER = new_number,
                WHERE  NUMBER = ENTRY.NUMBER;
        new_number := new_number + 1;
        ELSIF myCursor%NOTFOUND THEN
             EXIT;
        END IF;
    END LOOP;
END;

Now the problem is, the script runs BUT I am told there there was only one row updated (the last one, it seems).

Why is that?

I can put a

DBMS_OUTPUT.PUT_LINE(entry.number);

inside the loop and it will display all unique numbers found in TABLE with each iteration, so the loop itself seems to be working.

And just mabye…is there a way to do it without loop? Couldn’t come up with anything.

This script will be executed only once (as soon as it works) in preparation of test runs.

Thanks a lot im advance!

  • 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-15T10:07:34+00:00Added an answer on June 15, 2026 at 10:07 am

    Actually, all of you were right – as was even I in the first place. Thanks for your answers anyways, I appreciate it!

    The DBMS I am using (Hora) was configured to manually confirm every change. With every iteration it ‘overwrote’ the prompt to confirm/commit and only asked for the last change that occured.
    I had it changed and the script runs and does what it was supposed to now.
    Although Hora still only displays one row to be changed, it changes all of them now when commited.

    Thanks again.

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

Sidebar

Related Questions

The situation is this: I have a div with overflow auto containing a table.
I have this situation where I want to display a list of Administration objects
I have this situation: I have an entity, Person , that contains all personal
I want to do a data update using Oracle. I have a situation where
(Note: this is for MS SQL Server) Say you have a table ABC with
I have a situation where I want to connect two tables that do not
I have a situation that I would normally solve by creating a feeder table
I currently have a table in MySQL that stores values normally, but I want
I have a situation like this: create table a( a_id number(38) not null, constraint
I'm coming across this situation alot, I'll have a query that will have one

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.