====== pears.getwordex ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."getwordex" IS
{create function getwordex
/* Application Maintained Function / Procedure - DO NOT EDIT*/
(in s1 long varchar,in ln1 smallint,in sep char(10))
returns char(200)
begin
declare i smallint;
declare ln smallint;
declare s char(200);
set ln=ln1;
set s=s1;
loop1: loop
set ln=ln-1;
if ln <= 0 then
leave loop1
end if;
set i=charindex(sep,s);
if i > 0 then
set s=stuff(s,1,i,'')
else
set s=''
end if
end loop loop1;
set i=charindex(sep,s);
if i > 0 then
set s="left"(s,i-1)
end if;
return(s)
end
}