Subject | RE: [firebird-support] how to lpad in a stored procedure |
---|---|
Author | Alan McDonald |
Post date | 2005-02-21T00:30:27Z |
> I was browsing through the UDFs and saw a function I would like toAre you wanting this for a primary key? If so I wouldn't advise it. Needless
> 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
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