====== pears.MakeKeyName ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create function "pears"."MakeKeyName"(
/* Application Maintained Function / Procedure - DO NOT EDIT*/
in "sSource" char(60) )
returns char(60)
begin
declare "rv" char(60);
declare "isin" char(50);
declare "c" char(1);
set "rv" = '';
set "isin" = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ&0123456789';
set "isin" = "isin"+"char"(39);
if "isnull"((select "removespacesfromkeynames" from "params"),0) = 0 then
set "isin" = "isin"+' '
end if;
set "ssource" = "trim"("ucase"("csconvert"("ssource",'ascii')));
while "length"("ssource") > 0 loop
set "c" = "left"("ssource",1);
if "charindex"("c","isin") > 0 then
set "rv" = "rv"+"c"
end if;
set "ssource" = "stuff"("ssource",1,1,'')
end loop;
if "trim"("rv") = '' then set "rv" = 'UNKNOWN' end if;
return("rv")
end