Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Here is how to transform "DADD2PBA" to "DA2PPB"
Arjan van Bentem wrote
>I'd like to know how many different characters are in a string,
Meanwhile, I have come up with the following functions -- the names are not perfect yet. Ideas and comments welcome!
Arjan.
create or replace function usedChars( pStr in varchar2 ) return
varchar2
as
vResult varchar2(2000);
vChar varchar2(1);
begin
create or replace function sameChars ( pStr1 in varchar2
, pStr2 in varchar2 ) return varchar2is
create or replace function diffChars ( pStr1 in varchar2
, pStr2 in varchar2 ) return varchar2is
create or replace function usedAlphas( pStr in varchar2 ) return
varchar2
as
begin
return sameChars( pStr
, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' );
create or replace function usedNonAlphas( pStr in varchar2 ) return
varchar2
as
begin
return diffChars( pStr, usedAlphas( pStr ) );
end usedNonAlphas;
/
create or replace function usedNumerics( pStr in varchar2 ) return
varchar2
as
begin
return sameChars( pStr, '01234567890' );
end usedNumerics;
/
create or replace function usedNonNumerics( pStr in varchar2 ) return
varchar2
as
begin
return diffChars( pStr, usedNumerics( pStr ) );
end usedNonNumerics;
/
create or replace function usedAlphanumerics( pStr in varchar2 )
return varchar2
as
begin
return sameChars
( pStr , 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' );
create or replace function usedNonAlphanumerics( pStr in varchar2 )
return varchar2
as
begin
return diffChars( pStr, usedAlphanumerics( pStr ) );
end usedNonAlphanumerics;
/
create or replace function countUsedChars( pStr in varchar2 ) return
number
is
begin
return nvl( length( usedChars( pStr ) ), 0 );
end countUsedChars;
/
create or replace function countUsedAlphas( pStr in varchar2 ) return
number
is
begin
return nvl( length( usedAlphas( pStr ) ), 0 );
end countUsedAlphas;
/
create or replace function countUsedNonAlphas( pStr in varchar2 )
return number
is
begin
return nvl( length( usedNonAlphas( pStr ) ), 0 );
end countUsedNonAlphas;
/
create or replace function countUsedNumerics( pStr in varchar2 )
return number
is
begin
return nvl( length( usedNumerics( pStr ) ), 0 );
end countUsedNumerics;
/
create or replace function countUsedNonNumerics( pStr in varchar2 )
return number
is
begin
return nvl( length( usedNonNumerics( pStr ) ), 0 );
end countUsedNonNumerics;
/
create or replace function countUsedAlphanumerics( pStr in varchar2 )
return number
is
begin
return nvl( length( usedAlphanumerics( pStr ) ), 0 );
end countUsedAlphanumerics;
/
create or replace function countUsedNonAlphanumerics( pStr in
varchar2 )
return number
is
begin
return nvl( length( usedNonAlphanumerics( pStr ) ), 0 );
end countUsedNonAlphanumerics;
/
Received on Sun Oct 04 1998 - 08:14:58 CDT