Input to be printed in different output format I have a value (e.g. ORACLE) and I would like to print each letter on an individual line using an Oracle query.

Input value: 

ORACLE


Output:

O
R 
A
C
L
E
With PL/SQL find the length of string first,use substring to extract each character and print with dbms_output

BEGIN
  FOR ctr in 1..LENGTH('ORACLE')
  LOOP
   DBMS_OUTPUT.PUT_LINE(SUBSTR('ORACLE',ctr,1));
  END LOOP;
END;


or with declaring variables

DECLARE
l_str VARCHAR2(20):='ORACLE';
l_len INTEGER;
BEGIN
  l_len:=LENGTH(l_str);
  FOR ctr IN 1..l_len
   LOOP
    DBMS_OUTPUT.PUT_LINE(SUBSTR(l_str,ctr,1));
   END LOOP;
END;


Here is running pl/sql in sql*plus

SQL&gt; set serveroutput on
SQL&gt; DECLARE
  2  l_str VARCHAR2(20):='ORACLE';
  3  l_len INTEGER;
  4  BEGIN
  5    l_len:=LENGTH(l_str);
  6    DBMS_OUTPUT.PUT_LINE('Output:');
  7    FOR ctr IN 1..l_len
  8     LOOP
  9      DBMS_OUTPUT.PUT_LINE(SUBSTR(l_str,ctr,1));
 10     END LOOP;
 11  END;
 12  /
Output:
O
R
A
C
L
E

PL/SQL procedure successfully completed.

SQL&gt;