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

Why do we use joins?

554


Is merge a dml statement?

511


What are the types of triggers in sql?

486


What is a unique key and primary key and foreign key?

556


Can we group by two columns in sql?

495






What is the difference between clustered and non-clustered index in sql?

509


What is sql and how does it work?

534


What is the primary key?

526


What is a full join sql?

582


Can we use ddl statements in stored procedure?

687


How can you maintain the integrity of your database on instances where deleting an element in a table result in the deletion of the element(s) within another table?

659


Why do we create stored procedures & functions in pl/sql and how are they different?

496


What are different types of sql?

549


What is a left join?

493


How does an execution block start and end in pl sql?

491