The following function returns the delimited string
Now this function is been called as below
I get a runtime exception that string buffer too small as
I have v_fnGrp varchar2(1000);
and Function (fnc_get_delimited_str) puts a value into OUT param " l_result varchar2(32767)" that the caller cant cope with it . i.e v_fnGrp.
However the query
retuns only 3 rows Reporting , static Data , Report Data.
Since the SELECT distinct f.desc FROM User_Act U,func_grp f WHERE f.func_grp_id = u.func_grp_id returns the delimited string which is not more than 1000 char long.
it hardly makes any sense that Oracle throws error "String buffer too small i.e ORA-06502"
Please comment.
Code:
CREATE OR REPLACE FUNCTION GET_DELIMITED_STR
(
p_cursor sys_refcursor,
p_del varchar2 := ','
) return varchar2
is
l_value varchar2(32767);
l_result varchar2(32767);
begin
loop
fetch p_cursor into l_value;
exit when p_cursor%notfound;
if l_result is not null then
l_result := l_result || p_del;
end if;
l_result := l_result || l_value;
end loop;
return l_result;
end get_delimited_str;
Now this function is been called as below
Code:
select get_delimited_str(cursor
(SELECT distinct f.desc
FROM User_Act U,
func_grp f
WHERE f.func_grp_id = u.func_grp_id
))
into v_fnGrp
from dual;
I have v_fnGrp varchar2(1000);
and Function (fnc_get_delimited_str) puts a value into OUT param " l_result varchar2(32767)" that the caller cant cope with it . i.e v_fnGrp.
However the query
Code:
SELECT distinct f.desc FROM User_Act U,func_grp f WHERE f.func_grp_id = u.func_grp_id
Since the SELECT distinct f.desc FROM User_Act U,func_grp f WHERE f.func_grp_id = u.func_grp_id returns the delimited string which is not more than 1000 char long.
it hardly makes any sense that Oracle throws error "String buffer too small i.e ORA-06502"
Please comment.