PLS-00231: function error
587126Dec 9 2011 — edited Dec 11 2011version : Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
declare
v_mail_cust_code maz_sr_au_incentive_cust_hist.mail_cust_code%type;
function inc_uniq_code
return varchar2
is
v_unique_code maz_sr_au_incentive_cust_hist.mail_cust_code%type;
v_unique boolean := FALSE;
v_count number;
begin
while v_unique != TRUE
loop
select to_char(round(dbms_random.value(1000000,9999999))) into v_unique_code from dual;
select count(*) into v_count from maz_sr_au_incentive_cust_hist
where rtrim(mail_cust_code) = v_unique_code;
if v_count = 0 then
v_unique := TRUE;
end if;
end loop;
return v_unique_code;
end inc_uniq_code;
begin
select inc_uniq_code into v_mail_cust_code from dual;
dbms_output.put_line('inc_uniq_code : '|| v_mail_cust_code);
end;
error :
*************
ORA-06550: line 22, column 8:
PLS-00231: function 'INC_UNIQ_CODE' may not be used in SQL
ORA-06550: line 22, column 8:
PL/SQL: ORA-00904: "INC_UNIQ_CODE": invalid identifier
ORA-06550: line 22, column 1:
PL/SQL: SQL Statement ignored
Can someone help ?
Thanks
Raghu