Re: Splitting string on blanks in 4GL?
Posted in 1995
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Migration, Import/Export & Data Conversion, Platform-Specific Issues
}>>>>>>>>> Perry's response to Nils.Myklebust@CCMAIL.telemax.no <<<<<<<<<< I must warn you that the Informix substring manipulation is _exteremely_ expensive in the compiled version. I'd think about writing a routine in C to split your data. } Date: Mon, 14 Aug 1995 19:51:47 +0200 } From: Nils.Myklebust@CCMAIL.telemax.no } To: informix-list@rmy.emory.edu (Non Receipt Notification Requested) } Subject: Re: Splitting string on blanks in 4GL? } } } shj@dknet.dk (Stig Jacobsen) writes: } } Howdy, } } } } I have a bunch of strings which looks like "500 328 729", that } } I'd like to seperate by whitespace and store into integer } } variables - basically like: } } } } define str char(100) } } define counts array[3] of integer } } } } select value from table into str } } let counts = split(str, ...) } } I know of no way the above syntax can work in 4GL, but why not simply: } let counts[1] = str[1,3] } let counts[2] = str[5,7] } let counts[3] = str[9,11] } if your input data is as well formed as you indicate. } } If not a for loop will do it with variables for str[p_start,p_end] } possibly with a whenever any error continue and test on status } or perhaps better, tests inside the for loop on every character } in str. } If you don't have millions of rows with these data even the for } loop approach should be reasonably fast. } } } } } ... after which counts[1] equals 500, counts[2] is 328, etc. } } } } What is the best way to do this? } } } } I thought of unloading str to an ascii file, using run to call } } a shell script or somesuch which would massage the unload file } } and produce a load file, which is the loaded into a suitable } } table created on the fly. Pretty horrible thought, yes? I haven't } } tried it yet, but I expect it to be a lot slower than my users } } would appreciate. } } } } Any input is welcomed. } } } } I'm running INFORMIX-4GL Version 4.11.UC2 on Solaris 2.3. } } Nils.Myklebust@ccmail.telemax.no } NM-data, Dalsbergstien 7, N-0170 Oslo, Norway } My opinions are those of my company } } -perryd (Guru) ==================================================================== = Perry Dillard - CASE Tools Development Team Leader = = FourGen Software, Inc. = = FourGen Building = = 115 NE 100th Street = = Seattle, W.A. 98125-8098 = = = = e-mail: perryd@fourgen.com = ====================================================================