Re: Leading Zeros

Поиск
Список
Период
Сортировка
От David
Тема Re: Leading Zeros
Дата
Msg-id 20050804043218.GA5207@localhost.localdomain
обсуждение исходный текст
Ответ на Re: Leading Zeros  (<operationsengineer1@yahoo.com>)
Список pgsql-novice
On Wed, Aug 03, 2005 at 08:57:20PM -0700, operationsengineer1@yahoo.com wrote:
> --- Gordon Haverland <ghaverla@shaw.ca> wrote:
>
> > On Wednesday 03 August 2005 15:23, operationsengineer1@yahoo.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) . "')";
?>

В списке pgsql-novice по дате отправления:

Предыдущее
От:
Дата:
Сообщение: Re: Leading Zeros
Следующее
От: Dane Ensign
Дата:
Сообщение: string concatenation errors