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