How to find the count of letter "L" in HELLO

Answer Posted / dinesh

// in SQL:------------------------------------------
Select length('hello')-length(replace('hello','l','')) From
DUAL;

// IN PL/SQL:-------------------------------------------

create or replace Procedure count_char(name varchar2,c varchar2) IS
m number(11):=0;
d number(11);
a number(11);
b number(11):=1;
BEGIN
a:=length(name);
for i in 1..a
LOOP
IF INSTR(NAME,c,b)>=1 THEN
d:=INSTR(NAME,c,b);
m:=m+1;
b:=d;
END IF;
b:=b+1;
END LOOP;
DBMS_OUTPUT.PUT_LINE('count of '||' '||c ||' '||'is'||' '|| m||' '||'in'||' '||name);
end;

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to present a past time in hours, minutes and seconds? : Sql dba

734


What are reports usually used for?

751


How many joins can you have in sql?

683


What is a subquery in sql?

686


What is oracle sql developer?

786






What is synchronized subquery?

814


Explain the difference in execution of triggers and stored procedures?

741


Why we use pl sql?

700


Do foreign keys improve performance?

741


What is a native sql query?

693


what is the difference between delete and truncate commands? : Sql dba

713


What are the different datatypes available in PL/SQL?

748


Explain what is a column in a table?

758


What is pl sql in oracle?

777


how to use case expression? : Sql dba

728