Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

PLS-00231: function error

587126Dec 9 2011 — edited Dec 11 2011
version : 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
This post has been answered by William Robertson on Dec 11 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 8 2012
Added on Dec 9 2011
26 comments
7,174 views