How do I left pad a database column in FrontBase?
Posted
by
PleaseStand
on Stack Overflow
See other posts from Stack Overflow
or by PleaseStand
Published on 2011-11-14T01:48:32Z
Indexed on
2011/11/14
1:50 UTC
Read the original article
Hit count: 142
I have a table of items (let's call it WIDGET
) that each have their own eight-digit barcode numbers stored in a VARCHAR field (let's call it BARCODE
; the table's primary key is in a separate integer field ID
). My problem is that some personnel have omitted the leading zeros instead of entering the entire number while others have not. All new data is being entered with all eight digits present, but I would like to update all the existing records (several hundred in all) to eight digits for the sake of consistency.
1
→00000001
234
→00000234
5678
→00005678
00009012
→00009012
I know FrontBase supports all of SQL-92, but SQL-92 has no function specifically for left-padding strings. I already came up with a solution, but I am posting this question to see if anyone can think of a better way of doing this than I did.
© Stack Overflow or respective owner