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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:55:19+00:00 2026-06-15T15:55:19+00:00

I have a table that sometimes gets updated with records that miss a ‘0’

  • 0

I have a table that sometimes gets updated with records that miss a ‘0’ or several consecutive zeroes. The records length should be 8 digits beyond the decimal point (10 characters in total).

For example – a record that originally looks like 1.12345600 will end up like 1.123456

I made a script that checks all the records length and adds to each record that is shorter than 10 characters a ‘0’.

The problem is that it only add a ‘0’ once. The above example would look like 1.1234560 and not 1.12345600 as I want it.
This is the script :

DECLARE

       CURSOR dif IS
            SELECT CUST_CODE, CUST_ID, CONTRACT_NUM, MSISDN 
            FROM project1;


BEGIN

        FOR a in dif LOOP

            IF LENGTH (a.CUST_CODE)<10
            THEN
            UPDATE project1
            SET CUST_CODE=a.CUST_CODE||'0'      
            WHERE CUST_CODE=a.CUST_CODE;
            END IF;
        END LOOP;
        commit;

END;

After it finishes running, a single ‘0’ is added. If I’ll run the script again, it will add another ‘0’ to any records that is still shorter than 10 characters. Reocrds that have 7 characters would require running it a 3rd time.

I’m guessing there should be another loop somewhere to keep checking the records until it all reaches the required length.
Any idea?

  • 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-15T15:55:20+00:00Added an answer on June 15, 2026 at 3:55 pm

    You can use rpad function: http://www.techonthenet.com/oracle/functions/rpad.php (the third example in the link is what you want).

     SET CUST_CODE=rpad(a.CUST_CODE, 10, '0')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table (InnoDB) that gets inserted, updated and read frequently (usually in
I have table that gets dynamically created. When using jQuery and toggle, everything works.
i have this table of comments (little over 1 milion rows) that gets around
We sometimes write dataport scripts that rename tables or columns and have other complex
I have table that I insert data with following query (from c# code): INSERT
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have a table that contains multiple dropdown menus for a list of profile
I have a table that looks like this: id value AGA 0.211 AGA 0.433
I have a table that looks like this: CREATE TABLE foobar ( id SERIAL
I have a table that acts as a dropbox for files that get automatically

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.