Subject RE: CORRECTION Re: [firebird-support] formatting a number
Author Alan McDonald
> Hi all,
>
> The solution that I finally used was really simple
>
> /* format the new document number */
>
> if (New_No<10) then New_No_Tx = '0000'|| cast(New_No as VarChar(20));
> else if (New_No<100) then New_No_Tx = '000'|| cast(New_No as
> VarChar(20));
> else if (New_No<1000) then New_No_Tx = '00'|| cast(New_No as
> VarChar(20));
> else if (New_No<10000) then New_No_Tx = '0'|| cast(New_No as
> VarChar(20));
> else New_No_Tx = cast(New_No as VarChar(20));
>
> works for me.
>
> --
> Regards,
> Grant Brown

simple yet ugly...
when one line will do it

select f_padleft(FIELDNAME, '0', 20) from table

Alan