Subject Re: [firebird-support] zero's on the left side
Author Yves Glodt
On Wednesday 10 December 2003 18:29, Ronaldo Rezende Vilela Luiz wrote:
> How can I store integer numbers with 5 digits and 0 on the left side?

You have to store them in a varchar() field. And you have to add the
zeros yourself in your application, or in case you use a trigger/
generator to generate the integer, you can use something like this:

<snip>
declare variable pers_number integer;
declare variable prefix varchar(5);
begin
pers_number = gen_id(gen_pers_number,1);
prefix = substr('00000',1,5-strlen(pers_number)) || cast(pers_number as
varchar(5));
</snip>

UPDATE BLABLA SET PERS_NUMBER = :prefix WHERE ID = :ID;

regards,
Yves

> for example:
>
> 0 -> 00000
> 1 -> 00001
> 11 -> 00011
> 333 -> 00333
> 4444 -> 04444
>
>
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~--> Buy Ink Cartridges or Refill Kits for your
> HP, Epson, Canon or Lexmark Printer at MyInks.com. Free s/h on orders
> $50 or more to the US & Canada.
> http://www.c1tracking.com/l.asp?cid=5511
> http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/67folB/TM
> ---------------------------------------------------------------------
>~->
>
> To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/

--
Linux 2.4.22-1-k7 #1 Sat Sep 6 02:13:04 EST 2003 i686
18:57:18 up 34 min, 1 user, load average: 0.69, 0.65, 0.50