I experimented with the following code in many ways, such as by removing the while or the if, but whenever I combine the two (if and while), I consistently receive the error at the end.
set serveroutput on
accept numero prompt 'Type # between 100 and 999: '
c := №
d := length(c);
b := substr(c, i, 1);
while i <= d loop
if b = '1' then
a:= a||'one ';
i := i+1;
dbms_output.put_line('The number is '||a);
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at line 13
06502. 00000 - "PL/SQL: numeric or value error%s"
FIXED by changing how I declared the variable "a" to:
*Notice that here, the significant change is to use VARCHAR2 instead of CHAR (not the bigger length). According to @user272735 's answer, that's the key.