oracle - PL/SQL recursive function return no value -


i got error message while running oracle pl/sql recursive function

function returned without value

anyone knows might issue?

here's function

function cgic (cnt in number)    return varchar2          n_inv_code   varchar2 (20);       t_ic_chk                           number;    begin                   select dbms_random.string ('x', 10)       n_inv_code       dual;                    select count(*) t_ic_chk inv_code inv_code = n_inv_code , rownum = 1;        if t_ic_chk = 1                           n_inv_code := cgic(cnt);       else                     if t_ic_chk = 0                                                       return n_inv_code;                                 end if;       end if;    end cgic; 

in event t_ic_chk = 1

you assign value of recursive function variable: n_inv_code

however, don't it. want return it.

i recommend code in final section:

  if t_ic_chk = 1                   n_inv_code := cgic(cnt);   end if;   return n_inv_code; end cgic; 

that's need:

1) if find row, recurse in until can't find one, , return value. 2) if can't find row, return value back. 3) in event found row, hand-shake value returned whoever called you.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -