Path: news.easynews.com!core-easynews!newsfeed1.easynews.com!easynews.com!easynews!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!prodigy.com!news.cc.ukans.edu!stl-feed.news.verio.net!mozo.cc.purdue.edu!not-for-mail
From: "Oleg Fedorov" <ofedorov@purdue.edu>
Newsgroups: comp.databases.oracle.misc
Subject: Re: Help please with Oracle
Date: Mon, 5 May 2003 10:44:27 -0500
Organization: Purdue University
Lines: 41
Message-ID: <b960su$mg8$1@mozo.cc.purdue.edu>
References: <GSqta.92421$DT4.2849333@twister1.libero.it> <1052133780.672728@news.thyssen.com>
NNTP-Posting-Host: dyn-167-030.admin.purdue.edu
X-Trace: mozo.cc.purdue.edu 1052149470 23048 128.210.167.30 (5 May 2003 15:44:30 GMT)
X-Complaints-To: news@news.purdue.edu
NNTP-Posting-Date: Mon, 5 May 2003 15:44:30 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Xref: core-easynews comp.databases.oracle.misc:97322
X-Received-Date: Mon, 05 May 2003 08:49:48 MST (news.easynews.com)

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@triaton.com> wrote in message
news:1052133780.672728@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
>
>


