create or replace function wordcnt(sir varchar2) return number is
i number;
j number;
Result number;
begin
j:=0;
Result:=0;
i:=1;
while i<>0 loop
j:=j+1;
i:=instr(ltrim(rtrim(sir)),' ',1,j);
if i+1<>instr(ltrim(rtrim(sir)),' ',1,j+1) then Result:=Result+1;
end if;
end loop;
return(Result);
end wordcnt;
second step:
try something like this
select
'a tram named desire'
from dual
where wordcnt(substr('a tram named desire',1,instr('a tram named desire','desire')+length('desire')))=4
will have this output
a tram named desire
so...
in an abstract way is this:
select * from table
where wordcnt(substr(field,1,instr(field,searched_pattern)+length(searched_pattern)))=value_of_pozition_wanted
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.