Subject RE: [firebird-support] how to lpad in a stored procedure
Author Alan McDonald
> I was browsing through the UDFs and saw a function I would like to
> use, but don't know how.
>
> example of use
>
> CREATE PROCEDURE NEWCUST(sCU_NAME VARCHAR(40))
> RETURNS (oID CHAR(8)) AS
> BEGIN
> oID = GEN_ID(GEN_CU_ID, 1);
>
> INSERT INTO CUSTINFO(CU_ID, CU_NAME) VALUES (:oID, :sCU_NAME);
>
> END;
>
> Now assuming the generator was started at 1,
> how would I get oID set to 00000001
>
> Add this line below the Gen_ID line?
> oID = lpad(oID, 8, '0');
>
> Will that work ok in a stored Procedure and is there anything I need
> to do to free the resources?
>
> E. D. Epperson

Are you wanting this for a primary key? If so I wouldn't advise it. Needless
to say that you are changing the datatype here,... but in any case this
padding of integers is better carried out on the client application if you
just want to display padded numbers.
Alan