Print a no. digit by digit, as a series of words

Q. Write a program to read in a number and print it out digit by digit, as a series of words.

Answer:

For example: The number 321 printed as " three two one".

The decode function is used within a for loop in the following program.

DECLARE num varchar(10):='&number';
i varchar(1);
c int:=length(num);
RESULT varchar(10);
BEGIN dbms_output.put_line('Entered Number Is: ');
LOOP i:=substr(num,1,1);
num:=substr(num,2);
SELECT decode(i, 1, 'one', 2, 'two', 3, 'three', 4, 'four', 5, 'five', 6, 'six', 7, 'seven', 8, 'eight',9,'nine','zero') INTO RESULT
FROM dual;
dbms_output.put_line(RESULT);
exit WHEN c=1;
c:=c-1;
END LOOP;
END;
/


Output:

digit to words