2012-02-28 20 views

risposta

8

Si potrebbe simulare args var utilizzando un tipo di tabella come parametro.

create or replace type VARGS as table of varchar2(32767); 

È quindi possibile utilizzare questo tipo come ultimo parametro della funzione:

CREATE OR REPLACE Function FNC_COUNT_WITH_NAMES 
    (P_NAMES IN VARGS) 
    RETURN number 
IS 
RT_COUNT NUMBER; 
BEGIN 
    select count(*) INTO rt_count from employees where name IN 
    ( 
     select * from TABLE(p_names)) 
    ); 
    return rt_count; 
END; 

codice client chiamerebbe con:

exec FNC_COUNT_WITH_NAMES (vargs('Brian','Mike','John','David', 'Bob')); 

o

select FNC_COUNT_WITH_NAMES (vargs('Brian','Mike','John','David', 'Bob')) from dual; 
+3

Poiché si sta utilizzando una stringa in sql, è possibile limitare la stringa a 4000 caratteri – turbanoff

Problemi correlati