chainreaction
asked on
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.
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.
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
indicating how much leading zeroes you want to be added if you query this number back from the Db
>> 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
Changing the database field to string would of course be better if you can
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
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 ) ;
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 ) ;
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
5 * 8^4 + 1 * 8^3 + 6 * 8^2 + 2 * 8^1 + 3 * 8^0
ASKER
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..
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..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-( No points for me :-(
>> :-( No points for me :-(
Strange indeed
Strange indeed
I'm afraid not. For a number leading 0's have no meaning. So, why would they be stored in Oracle?