Re: Re: Padding with zeros

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: Re: Padding with zeros

Brian Johnson-2
I missed replying to the correct email, but this tip from Igor Tandetnik
worked beautifully:

Igor Tandetnik
Thu, 29 Dec 2005 14:50:08 -0800

Brian Johnson wrote:
I need to update a char field to add integer prefixes, but I need to
pad them with zeroes so I can sort them.

I'm not exactly sure what you are trying to do, but this would perhaps give
you an idea:

update table set field=substr('00...0' || field, -20, 20)

assuming you want your fields padded to 20 characters wide. Here '00...0' is a
string consisting of 20 '0' characters.

Igor Tandetnik