Search This Blog

Total Pageviews

Monday, 5 September 2011

Oracle Count alphabet

count in plsql



DECLARE
l_count_a NUMBER := 0;
l_string VARCHAR2(200);
l_string_length INTEGER;
BEGIN
l_string := 'eyryoeryaaasdflhaaaasdfhfhhhjaaasdfaffdsfaadsfdooo83u4384asdfaaaassssaaddAAAAA';

l_string_length := LENGTH( l_string );

FOR i IN 1..l_string_length LOOP
IF SUBSTR( l_string, i, 1 ) IN ( 'A', 'a' ) THEN
l_count_a := l_count_a + 1;
END IF;
END LOOP;

dbms_output.put_line( 'aA Count: ' || l_count_a );
END;
/

aA Count: 25

Oracle DBA

anuj blog Archive