Subject Re: Procedure for decimal to base36 conversion
Author Ian A. Newby
Hi Almond,

I use this procedure...

CREATE PROCEDURE SP_CONVERT_BASE(
BASE SMALLINT,
NUMBER BIGINT,
PADLENGTH SMALLINT)
RETURNS (
RESULT VARCHAR(1024))
AS
declare variable temp smallint;
declare variable chars char(62);
declare variable padding char(20);
begin
chars =
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
padding = '00000000000000000000';
result = '';
while (number >= base) do
begin
temp = number - ((number / base) * base);
result = substr(chars, temp +1, temp+1) || result;
number = number / base;
end
result = substr(chars,number+1, number+1) || result;
if (padlength is not null) then
begin
result = substr(padding, 1, padlength - strlen(result)) || result;
end
suspend;
end

Regards
Ian Newby