count, characters from string [message #215780] |
Tue, 23 January 2007 21:53 |
ashish_pass1
Messages: 114 Registered: August 2006 Location: delhi
|
Senior Member |
|
|
hello all
i want to count no. of characters from string .
suppose i enter 'ashish'.
then counter count
count character
------- ----------
1 a
2 s
2 h
1 i
2 s
2 h
also i need to remove the duplication i.e-
i dnt want repetition.
i did a query -
declare
v_str varchar2(1000);
v_chr varchar2:='a'
v_cnt number:=0;
begin
v_str:='&name';
for i in 1..length(v_str)
loop
if v_chr=substr(v_str, i, 1) then
v_cnt:=v_cnt+1;
end if;
end loop;
dbms_output.put_line('No of:'||v_chr||':'||v_cnt);
end;
/
enter value for name: ashish
no of: a:1
but i want, if i enter a string then it will count character of each without repetion.
please help me out by this puzzle, also please mentioned the comment so that it will help me to understand.
with regards
ashish
[Updated on: Tue, 23 January 2007 21:54] Report message to a moderator
|
|
|
|
|