Need UPPER( ) function
Posted in 1996
Topics: Stored Procedures & SPL, Data Types & Schema Design
I need a function to do the following:
select upper(column) from table
Where upper( ) will convert the value of 'column' to upper case. I found a
solution like the following:
--- cut here---
CREATE PROCEDURE upper (str VARCHAR(255)) RETURNING VARCHAR(255);
DEFINE i INTEGER;
DEFINE j INTEGER;
DEFINE retstr VARCHAR(255);
LET l = LENGTH(str);
LET retstr = '';
FOR i = 1 to l
IF str[l,1] BETWEEN "a" AND "z" THEN
IF str[1,1] = 'a' THEN
LET retstr = retstr || 'A';
...
ELIF str[1,1] = 'z' THEN
LET retstr = retstr || 'Z';
ELSE
LET retstr = retstr || str[1,1];
END IF
LET str = str[2,255];
END FOR
RETURN retstr;
END PROCEDURE;
--- cut here ---
Unfortunately I am using Informix-SE which does not support VARCHAR data
types so the above does not appear to work. When I use CHAR instead of
VARCHAR I get blank strings back from my procedure. Any help on this would
be most appreciated.
Chris Simpson