X-Original-To: pgsql-admin-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id C7B289FA159 for ; Sat, 10 Jun 2006 15:28:40 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 13152-07 for ; Sat, 10 Jun 2006 15:28:35 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id BF8B19F9AD3 for ; Sat, 10 Jun 2006 15:28:33 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id k5AISOls038824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 10 Jun 2006 12:28:27 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.6/8.13.6) with ESMTP id k5AISN4o091889; Sat, 10 Jun 2006 12:28:23 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.6/8.13.6/Submit) id k5AISNrf091882; Sat, 10 Jun 2006 12:28:23 -0600 (MDT) (envelope-from mfuhr) Date: Sat, 10 Jun 2006 12:28:23 -0600 From: Michael Fuhr To: Andy Shellam Cc: pgsql-admin@postgresql.org Subject: Re: Number formatting Message-ID: <20060610182823.GA91044@winnie.fuhr.org> References: <448B0C26.8070007@andycc.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <448B0C26.8070007@andycc.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/94 X-Sequence-Number: 22056 On Sat, Jun 10, 2006 at 07:15:02PM +0100, Andy Shellam wrote: > So, what I'm trying to do is use a primary key to generate invoice > numbers such as "INV0000001", "INV0000002" etc. Obviously a sequence > generates the increments, but when I try formatting it, it adds a space > at the beginning of the number. The FM modifier suppresses padding spaces. http://www.postgresql.org/docs/8.1/interactive/functions-formatting.html#FUNCTIONS-FORMATTING-DATETIMEMOD-TABLE test=> SELECT 'INV' || to_char(123, 'FM0000000'); ?column? ------------ INV0000123 (1 row) -- Michael Fuhr