[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Keep the '0' infront.

Posted on 2004-11-25
10
Medium Priority
?
365 Views
Last Modified: 2010-03-31
Hi there, I am having some difficulties in here.

When i have this data, 0051623 pass into my method and when i insert it into the Oracle 8i database declare as a NUMBER i will have this store "51623".

I wonder how can i make sure it'll store as 0051623? I can not format it as a Sting as the datatype is declare in Oracle as Number.

Any walk around here?

Do you have any existing method that can convert or keep the '0' infront?

Thank You.
0
Comment
Question by:chainreaction
10 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12673362
>> Do you have any existing method that can convert or keep the '0' infront?
I'm afraid not. For a number leading 0's have no meaning. So, why would they be stored in Oracle?
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12673368
If you like to keep them, I think you should add another field "leadingZeroes"
indicating how much leading zeroes you want to be added if you query this number back from the Db
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12673370
>> If you like to keep them, I think you should add another field "leadingZeroes"
Changing the database field to string would of course be better if you can
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:petmagdy
ID: 12673373
the Oracle Number field will not allow you, the only way maybe sutiable to u is to create additional String field to hold the 0 front string presentation
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12673410
As petmagdy says, this is a question about data and presentation (which are 2 seperate things)

Store it in the database as the number 51623, and when you show it to the user,  use

  DeciamlFormat df = new DecimalFormat( "#######" ) ;
  String output = df.format( number ) ;
0
 
LVL 15

Expert Comment

by:JakobA
ID: 12676405
Please also note that by default intial 0's on the number 51623  would be an indication that the numeric value should be interpreted as base 8 instead of the normal base 10. eg:
   5 * 8^4  +  1 * 8^3  +  6 * 8^2  +  2 * 8^1  +  3 * 8^0
0
 

Author Comment

by:chainreaction
ID: 12678024
TQ all.

This is the staging table. I am afraid it'll not be able to change the table schema.

Are you sure that NUMBER datafield in Oracle not able to store those 00 infront?

Can anyone have any padding method that can share with me?

TQ..
0
 
LVL 37

Accepted Solution

by:
zzynx earned 1000 total points
ID: 12679228
>> Are you sure that NUMBER datafield in Oracle not able to store those 00 infront?
Definitely

>>Can anyone have any padding method that can share with me?
You mean?  What about what Tim gave you:
DeciamlFormat df = new DecimalFormat( "#######" ) ;
String output = df.format( number ) ;
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12689733
:-(  No points for me :-(
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12693844
>>  :-(  No points for me :-(
Strange indeed
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses
Course of the Month19 days, 2 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question