I have the below user defined table:
CREATE OR REPLACE TYPE number_ntt AS TABLE OF varchar2(500);
Also I have the below function:
CREATE OR REPLACE FUNCTION TO_STRINGS (
nt_in IN number_ntt,
delimiter_in IN VARCHAR2 DEFAULT ','
) RETURN VARCHAR2 IS
v_idx PLS_INTEGER;
v_str VARCHAR2(32767);
v_dlm VARCHAR2(10);
BEGIN
v_idx := nt_in.FIRST;
WHILE v_idx IS NOT NULL LOOP
v_str := v_str || v_dlm || nt_in(v_idx);
v_dlm := delimiter_in;
v_idx := nt_in.NEXT(v_idx);
END LOOP;
RETURN v_str;
END TO_STRINGS;
/
EXIT;
I have the below two tables:(Image attached)
Now, I am running the below query:
SELECT A.PERSONNUMBER,
(select TO_STRINGS
(CAST(COLLECT(C.LOCATIONNAME) as number_ntt)
) AS cnt
from client.Tab_EMPLOYEES B JOIN client.Tab_Locations C ON B.MOBILELOCATIONID = C.MOBILELOCATIONID
WHERE B.PERSONNUMBER = A.PERSONNUMBER) as Assignedlocations
FROM client.Tab_EMPLOYEES A WHERE A.MOBILELOCATIONID = '100';
But I am getting the below error:
ORA-06502:PL/SQL:numeric or value error:character string buffer too small ORA-06512:at line 1.
I believe either I need to modify the TO_STRINGS
function or the query; any help will be highly appretiated.
Thanks in advance.