Write a PL/SQL program to convert 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 convert text

PL/SQL program to convert text


Program:

DECLARE
ttext VARCHAR2(25) := 'this is to convert text';
len_of_text NUMBER;
extract_text VARCHAR2(1);
after_space VARCHAR2(1) := 'T';
change_text VARCHAR2(25);
--yes_cap VARCHAR2(1) := 'T';


BEGIN
len_of_text := LENGTH(ttext);

FOR for_check IN 1 .. len_of_text
LOOP
extract_text := SUBSTR(ttext, for_check,1);


IF extract_text = ' '
THEN
change_text := change_text || extract_text;
after_space := 'T';

ELSIF extract_text <> ' '
THEN
IF after_space = 'T'
THEN
change_text := change_text || LOWER(extract_text);
ELSIF after_space = 'F'
THEN
change_text := change_text || UPPER(extract_text);
END IF;
after_space := 'F';
END IF;

END LOOP;
dbms_output.put_line(change_text);


END;

No comments:

Post a Comment