How to use pass an array in PL/SQL function

Viewed 57202

I am a Java developer with limited knowledge of Oracle PL/SQL. Please let me know how to pass an array to a PL/SQL function in the following example and how to invoke it.

CREATE OR REPLACE FUNCTION get_employees (pUserId NUMBER)
  RETURN VARCHAR2
IS
  l_text  VARCHAR2(32767) := NULL;
BEGIN
  FOR cur_rec IN (SELECT grp.NAME GROUP_NAME FROM UserGroupRole ugr, Group_ grp WHERE ugr.groupid=grp.groupid and USERID = pUserId) LOOP
    l_text := l_text || ',' || cur_rec.GROUP_NAME;
  END LOOP;
  RETURN LTRIM(l_text, ',');
END;
/

SELECT get_employees(414091) FROM DUAL;
1 Answers
Related