CREATE OR REPLACE TYPE t_in_list_tab AS TABLE OF VARCHAR2 (4000);
/
CREATE OR REPLACE FUNCTION in_list (p_in_list IN VARCHAR2)
RETURN t_in_list_tab PIPELINED
AS
l_text VARCHAR2(32767) := p_in_list || ',';
l_idx NUMBER;
BEGIN
LOOP
l_idx := INSTR(l_text, ',');
EXIT WHEN NVL(l_idx, 0) = 0;
PIPE ROW (TRIM(SUBSTR(l_text, 1, l_idx - 1)));
l_text := SUBSTR(l_text, l_idx + 1);
END LOOP;
RETURN;
END;
SELECT *
FROM emp
WHERE empno IN (SELECT * FROM TABLE(in_list(:empno)))
ORDER BY ename
Value of :empno is 7876,7934,7782
No comments:
Post a Comment