Для этого вам не нужен PL / SQL.
SQL> set ver off
SQL>
SQL> select sum(dig) result
2 from (select substr(&&enter_number, level, 1) dig
3 from dual
4 connect by level <= length(&&enter_number)
5 );
Enter value for enter_number: 245
RESULT
----------
11
Переписать его в функцию просто:
SQL> create or replace function f_dig (par_enter_number in number)
2 return number
3 is
4 retval number;
5 begin
6 select sum(dig)
7 into retval
8 from (select substr(par_enter_number, level, 1) dig
9 from dual
10 connect by level <= length(par_enter_number)
11 );
12 return retval;
13 end;
14 /
Function created.
SQL> select f_dig(245) result_1,
2 f_dig(189) result_2,
3 f_dig(9834188) result_3
4 from dual;
RESULT_1 RESULT_2 RESULT_3
---------- ---------- ----------
11 18 41
SQL>