|
Tiya Khambadkone wrote:User can enter on the GUI as account number = '234567' but database column could have the value of '0000234567' . Still it should match.
Tiya Khambadkone wrote:account_number in database is a VARCHAR(40) and that may or may not contain leading zeros. Also how many leading zeros is again not known.
Tiya Khambadkone wrote:Isn't it obvious that one could seek answer on another community if not getting from one community.
Please let me know if it is a sin to post questions on 2 websites?
Tiya Khambadkone wrote:I thought the whole purpose of SO or Code Ranch is to help people and the IT community and grow knowledge.
It should not matter which community answers questions.
Tiya Khambadkone wrote:I would have been glad if you would have helped me with the issue and then lectured about code ranch guidelines.
Tiya Khambadkone wrote:account_number in database is a VARCHAR(40) and that may or may not contain leading zeros. Also how many leading zeros is again not known. It could be '000123' or '00123' or just '123'
Tiya Khambadkone wrote:account_number in database is a VARCHAR(40) and that may or may not contain leading zeros. Also how many leading zeros is again not known. It could be '000123' or '00123' or just '123'
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Tiya Khambadkone wrote:Why will this be a bad database structure design ?
Seems reasonable...Tiya Khambadkone wrote:The account number is alpha-numeric . so it makes sense to define it as varchar(40).
...but that is NOT.The length is not certain. It could be 'H122' or '0000012345'.
Sounds to me like you're guessing here.I need to trim the padded zeroes if they are present while fetching from the database.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Tiya Khambadkone wrote:The account number is alpha-numeric . so it makes sense to define it as varchar(40). The length is not certain. It could be 'H122' or '0000012345'.
I need to trim the padded zeroes if they are present while fetching from the database.
Tiya Khambadkone wrote:
the account_number couldbe '000012345' or '00012345' or '12345' but this all should refer to the same row. It is unique. They can not co-exist in the database table.
Tiya Khambadkone wrote:oh. you misundersstood !
I might not be clear while explaining .
the account_number could be '000012345' or '00012345' or '12345' but this all should refer to the same row. It is unique. They can not co-exist in the database table.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Tiya Khambadkone wrote:instead of ltrim if I use LEADING '0' , it works
Tiya Khambadkone wrote:I have decided to go with native sql query :
select ltrim(account_number, '0')
This ORACLE query works as expected on SQL developer but when i try to run it using hibernate... it complains :
Caused by: java.sql.SQLSyntaxErrorException: unexpected token: ,
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Tiya Khambadkone wrote:
For now, I am worrying about if the TRIM should be used at database level or java level ? which is more expensive? any thoughts?
Tiya Khambadkone wrote:The account table has account_number column with values such as '00012345','0012345','12345','54564654','2343433'. the length of column is varchar40
So it seems you don't have a clue yourself about what's considered to be normal (and expected) behavior. And that makes it for others unfortunately impossible to help you...Tiya Khambadkone wrote:the account_number couldbe '000012345' or '00012345' or '12345' but this all should refer to the same row. It is unique. They can not co-exist in the database table.
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|