Re: Manipulating strings in SQL, SPL
Posted in 1997
Jacob Salomon <jake@apparel.net> wrote: :Tin Zaw wrote: :> :> I am trying to do following in an Informix stroed procedure: :> :> DEFINE string CHAR(80); :> DEFINE another CHAR(80); :> DEFINE substring CHAR(4); :> DEFINE number INT; :> -- Copy first 4 characters from "string" to "substring" :> -- convert "substring" to "number" (integer type) to do calculation :> -- concatenate "substring" to "anotherstring" :> :> Are there any functions that manipulate strings and do type :> conversions? A cc: will be much appreciated. : :Tin, : :these are mostly easy enough: : :let substring = string[1,4] -- Character positions 1 through 4 : -- Calculations I don't know about You simply do: let number = substring You could also directly do: let number = string[1,4] Informix do the conversion for you automatically. :let anotherstring = anotherstring || substring : :There, that's 2 out of 3. : :Luckily, you know exactly which character positions you needed. As of :my current knowlege (release 7.2), SPL does not (yet) support a variable :subscript in a string. eg. : let xyz = string[m,n] :where m and n are integer variables. So true, it would be very helpfull to have this. Nils.Myklebust@idg.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company The Informix FAQ is at http://www.iiug.org