Thread: padding an integer ...

padding an integer ...

From
"Marc G. Fournier"
Date:
Is there any way of "padding" an integer, similar to how, in perl, I would 
do:

printf("%03d", 1);

to get:

001

Specifically, I'm looking to do this in a pl/pgsql function ... like to 
avoid moving to pl/php or pl/perl if I can ... but, from what I've been 
able to find, I suspect I'm not going to have much of a choice ...

----
Marc G. Fournier           Hub.Org Networking Services (http://www.hub.org)
Email: scrappy@hub.org           Yahoo!: yscrappy              ICQ: 7615664


Re: padding an integer ...

From
Michael Fuhr
Date:
On Wed, Oct 26, 2005 at 12:57:25AM -0300, Marc G. Fournier wrote:
> Is there any way of "padding" an integer, similar to how, in perl, I would 
> do:
> 
> printf("%03d", 1);
> 
> to get:
> 
> 001

test=> SELECT to_char(1, '000');to_char 
--------- 001
(1 row)

http://www.postgresql.org/docs/8.0/interactive/functions-formatting.html

-- 
Michael Fuhr