Character subscripts in SPL
Posted in 2005
Topics: Stored Procedures & SPL
I am trying to write a procedure to strip out all characters in a string after a certain character (in this case "-") is reached. I was expecting to be able to do something like this..... LET l_length = LENGTH (l_custnote); FOR l_index = 1 TO l_length IF l_custnote[l_index] = "-" THEN EXIT FOR; END IF; LET l_newnote[l_index] = l_custnote[l_index]; END FOR; but when I run it I get a syntax error. If this possible in SPL? Thanks Greg Bunting.
Perhaps the reference to a substring is wrong. IIRC Informix doesn't allow a {} reference for anything except the leading position. Try something along the lines of: LET l_newnote = ""; ... IF SUBSTRING(p_indate FROM l_index FOR 1) = "-" THEN And create the new string with concatenation: ELSE LET l_newnote = l_newnote || SUBSTRING(p_indate FROM l_index FOR 1); ... There are probably prettier ways to do this. HTH Greg Williamson DBA GlobeXplorer LLC -----Original Message----- From: forum.subscriber@iiug.org on behalf of Greg Bunting Sent: Wed 5/18/2005 3:26 AM To: ids@iiug.org Cc: Subject: Character subscripts in SPL [4990] I am trying to write a procedure to strip out all characters in a string after a certain character (in this case "-") is reached. I was expecting to be able to do something like this..... LET l_length = LENGTH (l_custnote); FOR l_index = 1 TO l_length IF l_custnote[l_index] = "-" THEN EXIT FOR; END IF; LET l_newnote[l_index] = l_custnote[l_index]; END FOR; but when I run it I get a syntax error. If this possible in SPL? Thanks Greg Bunting. !DSPAM:428b1ce282251395011244!