oracle - Function to count words, from not where expected -


i trying function count words in string ignoring spaces, dots, comas, etc... started ignoring simple spaces, far works

select length ('hello world') - length(regexp_replace('hello world', '( ){1,}', '')) numdepalabras + 1 dual; 

but when trying make function gets parameter string , return number or words isn't working right error keyword not found expected.

any ideas of how can work?

 create or replace function wcount        ( txt in varchar2 )         return varchar2             resul varchar2(100);      begin       select length (txt) - length(regexp_replace(txt,     '( ){1,}', '')) numdepalabras + 1 dual;      return resul;      exception     when others        raise_application_error(-20001,'se ha encontrado un error - '||sqlcode||' -error- '||sqlerrm);     end; 

sql>     create or replace function countword(txt varchar2) return varchar2   2      resul varchar2(100);   3      begin   4   5      select (length (txt) - length(regexp_replace(txt,'( ){1,}', '')) ) resul dual;   6   7      return resul+1;   8   9      exception  10      when others  11         raise_application_error(-20001,'se ha encontrado un error - '||sqlcode||' -error- '||sqlerrm);  12      end;  13  /  function created.  sql> 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -