====== pears.Base29Safe ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."Base29Safe" IS
{create function Base29Safe
/* Application Maintained Function / Procedure - DO NOT EDIT*/
(in seed integer,in digits smallint)
returns char(20)
begin
declare rv char(20);
declare m integer;
declare sdigits char(29);
-- Where the code must be handled by humans, letters O and I can be confused with zero and one so these are left out
-- By removing all vowels and also 1 & 0 from the available characters (except the padding) nothing that
-- looks much like a word (rude or otherwise) should be generated
set sdigits='23456789BCDFGHJKLMNPQRSTVWXYZ';
set rv='';
if((digits > 20) or(digits < 1)) then
set digits=20
end if;
while seed > 0 loop
set m=mod(seed,29);
set rv=substr(sdigits,m+1,1) || rv;
set seed=seed/29
end loop;
set rv="right"(string('0000000000000000000',rv),digits);
return(rv)
end
}