mask to insert spaces before text?


Author
Message
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (283 reputation)StrataFrame User (283 reputation)StrataFrame User (283 reputation)StrataFrame User (283 reputation)StrataFrame User (283 reputation)StrataFrame User (283 reputation)StrataFrame User (283 reputation)StrataFrame User (283 reputation)StrataFrame User (283 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
I have certain codes (example: customer code) that can have numbers or alphanumerical characters example "AB123" or "123" or "123AB"



If I save some customer codes like "1" "2" and "11", when I try to order by this field the "11" will be on 2nd place



1,

11

2



only if I put a space before the number will be orderer ok ( " 1", " 2", "11")



1

2

11



what do you recommend to do ? can I only add spaces when I like to persist the code that a user enter on the field to the DB to order it correctly? how is the best to do this?

Thanks for any suggestion.
Edhy Rijo
E
StrataFrame VIP (5.6K reputation)StrataFrame VIP (5.6K reputation)StrataFrame VIP (5.6K reputation)StrataFrame VIP (5.6K reputation)StrataFrame VIP (5.6K reputation)StrataFrame VIP (5.6K reputation)StrataFrame VIP (5.6K reputation)StrataFrame VIP (5.6K reputation)StrataFrame VIP (5.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Fabian,

I have done that but in VFP.  What I did was to convert or cast the field to integer so it will sort the way I needed to.  I think you may do something like that to get the proper sorting by casting the field, but keep in mind that when you cast values like ABC will have no meaning, only the digits will be casted.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (13K reputation)StrataFrame Developer (13K reputation)StrataFrame Developer (13K reputation)StrataFrame Developer (13K reputation)StrataFrame Developer (13K reputation)StrataFrame Developer (13K reputation)StrataFrame Developer (13K reputation)StrataFrame Developer (13K reputation)StrataFrame Developer (13K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You can case it as Edhy mentioned, or perform the query and pad the results in the off chance that you have an illegal integer value which would then result in an error.  So I would probably just create a query that brings the data back with the padding versus trying to manage this within the BO itself.  This would also be the fastest in regards to performance.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search