create or replace FUNCTION GETNAMES(numero CREATURE.CREATUREID%type) return varchar2 is chaine varchar2(200); type tableOfNames is table of CreatureName.creatureNameId%type index by BINARY_INTEGER; myTable tableOfNames; begin chaine:='['; select creatureNameId bulk collect into myTable from CreatureName where CREATUREID=numero; if(myTable.count>1) then FOR i IN myTable.FIRST .. myTable.LAST-1 LOOP chaine:=chaine||myTable(i)||','; end loop; chaine:=chaine||myTable(myTable.LAST); else if(myTable.count=1) then chaine:=chaine||myTable(1); end if; end if; chaine:=chaine||']'; return chaine; end;