| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Help please with Oracle
Function My_Count(p_string varchar2,p_character char) return number is
begin
return LENGTH(p_string||'.')-LENGTH(REPLACE(p_string||'.',p_character));
end;
"Guido Konsolke" <Guido.Konsolke_at_triaton.com> wrote in message
news:1052133780.672728_at_news.thyssen.com...
> "Limner" wrote...
> >
> > Hi to all
> >
> > i've a question.
> > I need to know how to count how many times it present a particular
> caracter
> > in a varchar2 field ( i've oracle 9i )
> >
> > For example: " Pippo|pluto|paperino" and i want to know how many
> times
> > is present the caracter "|" ( 2 times )
> >
> > can someone help me in this ??
> >
> > Thanks in advance
> >
> > Danilo
> >
> Hi Danilo,
>
> until someone offers a better solution, here's an ugly one:
> you have to eliminate all characters that are not '|'. This can be done
> by using the REPLCAE function. You will need to provide *every* character
> that *might* occur. Step 2 is to wrap this monster with the LENGTH()
> function.
>
> hth and someone does better,
>
> Guido
>
>
Received on Mon May 05 2003 - 10:44:27 CDT
![]() |
![]() |