Re: subscripts in stored procedures.
Posted in 1998
John H. Frantz — — source: Informix-list mailing list archive (1991-1998)
June Tong provided the following clever solution which is in the FAQ
(http://www.iiug.org/techinfo/faq):
--
-- Procedure: GetCharAt()
-- Get a character from a string at a specified position.
--
DROP PROCEDURE GetCharAt;
CREATE PROCEDURE GetCharAt(str VARCHAR(255), pos INTEGER)
RETURNING VARCHAR(1); DEFINE i INTEGER;
IF pos > 1 THEN
FOR i = 2 TO pos
LET str = str[2,255];
END FOR;
END IF
RETURN str[1,1];
END PROCEDURE;
----------------------------------------------------------------------
John H. Frantz Power-4gl: Extending Informix-4gl
john@rl.is http://www.rl.is/~john/pow4gl.html