--execute as DBCGO
create or replace FUNCTION getnomefileTCR(id_ric IN VARCHAR2) RETURN VARCHAR2
-- dato l'id_richiesta ritorna una stringa con la lista dei nomi file STCR
AS
nome_file_tcr VARCHAR2(2000);
CURSOR cur_tcr (id_ric IN VARCHAR2)
IS SELECT nome_file FROM MNP_DWH_XML_IN WHERE id_richiesta=id_ric AND tipo_file = 10;

BEGIN
nome_file_tcr:='';

FOR rec IN cur_tcr(id_ric)  LOOP
       nome_file_tcr:=nome_file_tcr || '  ' || rec.nome_file;
END LOOP;

RETURN nome_file_tcr;

END; 
/
