Unix Technical Forum

padding an integer ...

This is a discussion on padding an integer ... within the pgsql Sql forums, part of the PostgreSQL category; --> Is there any way of "padding" an integer, similar to how, in perl, I would do: printf("%03d", 1); to ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 11:52 AM
Marc G. Fournier
 
Posts: n/a
Default padding an integer ...


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

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 11:52 AM
Michael Fuhr
 
Posts: n/a
Default Re: padding an integer ...

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/i...ormatting.html

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:22 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com