0
votes

I have multi-select drop down list where in user can select multiple options, now how can I pass this multi-select options to select query.

Code

select number from table(get_number(('('1','2','3','4','5')','7','8')));

where 1, 2, 3, 4 and 5 are the multi-select options selected from multiselect dropdown box. Now in get_number function I am passing count_number, role_number and test_id. Count_number represents the multi-select options which user select. So my question is how can I consume multi-select values which user entered in my get_number function, not sure if possible but do I need to define count_number as array in get_number function ?

1
Am I missing out to mentioned something in the question or the question itself is not clear ? - Rachel

1 Answers

0
votes

it is not clear what you're trying to achieve. Below is an example of a function that uses arrays as parameter and output.

SQL> CREATE OR REPLACE TYPE tab_number AS TABLE OF NUMBER;
  2  /

Type created

SQL> CREATE OR REPLACE FUNCTION get_number (p_array tab_number)
  2     RETURN tab_number
  3  IS
  4     l_result tab_number := tab_number();
  5  BEGIN
  6     FOR i IN 1..p_array.count LOOP
  7        /* do something with array */
  8        l_result.extend;
  9        l_result(i) := 2 * p_array(i);
 10     END LOOP;
 11     RETURN l_result;
 12  END;
 13  /

Function created

SQL> SELECT * FROM TABLE(get_number(tab_number(1,2,3,4,5)));

COLUMN_VALUE
------------
           2
           4
           6
           8
          10