[ic] Increment integer with preceding zeros

Peter peter at pajamian.dhs.org
Sat Apr 5 22:08:21 CDT 2008


On 04/05/2008 08:00 PM, Peter wrote:
> On 04/05/2008 07:05 PM, Grant wrote:
>> Is there a way to increment an integer like 000001 to end up with
>> 000002?  The integer is stored in a MySQL table.
> 
> 
> Of course, there's a few different ways.  If you give some more details 
> of what you're trying to do, though, it will be easier to give an 
> appropriate answer to your question.  Where do you want the increment to 
> occur, and when, etc?

I'll give you a bit of code you can use in perl to do it:

$i = sprintf('%0' . length($i) . 'd', $i + 1);

Peter




More information about the interchange-users mailing list