From: | David <dbree(at)duo-county(dot)com> |
---|---|
To: | operationsengineer1(at)yahoo(dot)com |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Leading Zeros |
Date: | 2005-08-04 04:32:18 |
Message-ID: | 20050804043218.GA5207@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Wed, Aug 03, 2005 at 08:57:20PM -0700, operationsengineer1(at)yahoo(dot)com wrote:
> --- Gordon Haverland <ghaverla(at)shaw(dot)ca> wrote:
>
> > On Wednesday 03 August 2005 15:23, operationsengineer1(at)yahoo(dot)com wrote:
> > > can i use pgsql to force th einput of leading zeros?
> > > i have an application that enters serial numbers within a range,
> > > eg, 00001 to 00003.
> > Use a string type, but only allow certain characters.
> Gord,
>
> if i do that, though, i think i'm unable to increment
> the number string in php. the user inputs the
> beginning and ending s/n only. i use php to create
> and enter the other s/ns. can i still increment a
> number string using i++?
You probably could do it as a string in php, but I think I'd use it as a
decimal in php, and then use a printf() statement when you do an insert.
Like this example (where mycol is of some string type):
<?php
$num = 12;
$sql = "INSERT INTO table (mycol), VALUES('" .
printf("%06d",$num) . "')";
?>
From | Date | Subject | |
---|---|---|---|
Next Message | Dane Ensign | 2005-08-04 04:41:31 | string concatenation errors |
Previous Message | operationsengineer1 | 2005-08-04 03:57:20 | Re: Leading Zeros |