Keep the '0' infront.

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.
chainreactionAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zzynxSoftware engineerCommented:
>> 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
zzynxSoftware engineerCommented:
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
zzynxSoftware engineerCommented:
>> 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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

petmagdyCommented:
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
TimYatesCommented:
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
JakobACommented:
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
chainreactionAuthor Commented:
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
zzynxSoftware engineerCommented:
>> 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TimYatesCommented:
:-(  No points for me :-(
0
zzynxSoftware engineerCommented:
>>  :-(  No points for me :-(
Strange indeed
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.