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;
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;