RE: ORACLE substr in INFORMIX
Posted in 1998
----------
Volker Fraenkle (VFraenkle@cs-controlling.de) wrote:
>Is there a possibility to copy the substr command from oracle. I
>developed following SP:
>create procedure cs_substr (cString char(255), iFPos smallint, iLen
integer)
>returning char(255);>
>return cString[iFPos, iFPos + iLen - 1];
>
>end procedure;
>While running via dbaccess following error occurs:
>201: A syntax error has occurred.
>Error in line 5>Near character position 17
>When I switch to
>return cString[15,15];
>the SP will be created. What is my problem?
Your problem is trying to use anything other than a literal integer in the
SPL substring operation. Yes, SPL is brain dead, and has been since birth,
especially on this point (and also for requiring semicolons).
The simplest fix is to upgrade to 7.30 which has a SUBSTR() built-in
function - Hooray!
Failing that, you end up writing excessively slow code which assembles and
disassembles strings one (or a few) characters at a time.
Yours,
Jonathan Leffler (jleffler@visa.com) #include <bother.ms-exchange.h>