Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Informix SPL while loop

Status
Not open for further replies.

fanik

Programmer
May 26, 2010
5
MK
I'm working with informix database and i need to create some procedure/function which returns the first or the second or etc. word from the string char(100). I need some instruction or tutorial or written procedure. I have written some procedure but it doesn't work. Here is the code: ( telnet: A syntax error has occurred on the line: let pom2=pom1[i,i];)


create procedure word(naziv char(100), br integer) returning char(50);

define str1 char(200);
define j smallint;
define len,i integer;
define pom char(100);
define pom1 char(100);
define pom2 char(100);
define pom3 char(100);

--set debug file to 'err.sql';
--trace on;

let len = length(trim(naziv));
let pom=trim(naziv);
let pom1=trim(naziv);
let pom3=' ';
let pom2=pom1[1,1];
let j=1;
let i=0;
let k=br;
if k=0 then return pom3;
while j<len
let i=i+1;
let pom2=pom1[i,i];
if pom2=' ' then
if length(pom1[(i+1),len])=length
(trim(pom1[(i+1),len])) then let k=k-1;
end if;
end if;
if k=0 then let j=len;
let pom=pom1[1,(i-1)];
let pom1=pom1[(i+1),len]
else j=j+1;
end if;

end while;
return pom;
--trace off;
end procedure;

 
The same question i have sent on other
forum - Informix solution.
Thanks for understanding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top