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: 138

Filed under:
|

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.

  • 100000001
  • 23400000234
  • 567800005678
  • 0000901200009012

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

Related posts about sql

Related posts about frontbase