Write a PL/SQL program to Count the number of characters and numbers in a given text - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Thursday, October 5, 2017

Write a PL/SQL program to Count the number of characters and numbers in a given text

Count the number of characters and numbers in a given text

Program:

DECLARE

PROCEDURE cnt_char_numb(name VARCHAR2)

IS

extracted_letter VARCHAR2(1);

cnt_numb NUMBER :=0;

cnt_char NUMBER := 0;



BEGIN



FOR i IN 1 .. LENGTH(name)

LOOP

extracted_letter := SUBSTR(name,i,1);

IF TO_CHAR(extracted_letter) IN ('0','1','2','3','4','5','6','7','8','9')THEN

cnt_numb := cnt_numb + 1;

ELSE

cnt_char := cnt_char + 1;

END IF;

END LOOP;



dbms_output.put_line('no of number : ' || cnt_numb);

dbms_output.put_line('no of char : ' || cnt_char);

END;

BEGIN

cnt_char_numb('snoopy123');


END;

No comments:

Post a Comment