pears.proper
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"."proper" IS {CREATE FUNCTION proper /* Application Maintained Function / Procedure - DO NOT EDIT*/ (IN OldString CHAR(255)) RETURNS CHAR(255) BEGIN DECLARE NewString CHAR(255); DECLARE StringLength SMALLINT; DECLARE CurrentChar CHAR(1); DECLARE LastChar CHAR(1); DECLARE CurrentPos SMALLINT; IF OldString IS NULL THEN RETURN(NULL) END IF; SET oldstring=LOWER(oldstring); SET stringlength=LENGTH(OldString); SET CurrentPos=1; SET NewString=''; process: loop SET CurrentChar=substr(OldString,CurrentPos,1); IF CurrentPos = 1 THEN SET currentchar=UPPER(currentchar) ELSE SET LastChar=substr(OldString,CurrentPos-1,1); IF ascii(LOWER(lastchar)) NOT BETWEEN 97 AND 122 AND(ascii(lastchar) NOT BETWEEN 128 AND 154) AND(ascii(lastchar) NOT BETWEEN 160 AND 165) THEN SET CurrentChar=UPPER(CurrentChar) END IF END IF; SET NEWString=Newstring || CurrentChar; SET CurrentPos=CurrentPos+1; IF CurrentPos > StringLength THEN leave process END IF END loop process; RETURN(NewString) END }