Re: Need Stored Procedure for case conversion
Posted in 1997
Topics: Stored Procedures & SPL
JB In answer to your question, it can be done but it is not elegant and rather inflexible in versions of informix prior to V7. In V7, I think you will find they have implemented a stored procedure for this, but since I do not know for sure, don't take my word on it. To to it yourself: You end up having to write a function to compare the current letter against the 26 lowercase letters: PROCEDURE change_case(ch CHAR) RETURNING CHAR; IF ch = 'a' THEN LET ch='A'; END IF IF ch = 'b' THEN LET ch ='B'; END IF RETURN ch; END PROCEDURE; PROCEDURE to_upper(str CHAR(50)) RETURNING CHAR(50); DEFINE strlen SMALLINT; LET strlen = length(str); IF strlen >= 1 THEN LET str[1] = change_case(str[1]); END IF IF strlen >= 2 THEN LET str[2] = change_case(str[2]); -- All the way to 50! END IF RETURN str; END PROCEDURE;