title: pl/sql: select as argument/parameter of function in oracle
body: <p>I've got problem with creating function. I'll try explain what the problem is:</p>
  
  <p>The task is about creating function which is based on <code>select first_name from employees where dept_id=10;</code>. New function MUST have v_select_statement (which I wrote) as argument(sth like this: <code>v_select_statement := select first_name from employees where dept_id=10;</code>. Selet like you can see generating list of names. These names should be in new table which is created in this function too. New table should have name e.g new_table.
  Problem is that I don't know how to do it. I tried something like this:</p>
  
  <pre><code>create or replace
  
  FUNCTION create_new_tab (v_select_statement VARCHAR2) RETURN NUMBER
  is
  b first_name.employees%TYPE;
  
  begin
  
  --here i don`t know how to assign select statement to cursor or execute immediate. Any ideas? i tried create sth like:
  -- execute immediate 'v_select_statement into b ';
  
  
  execute immediate 'CREATE TABLE new_tab (i VARCHAR2(50))';
  execute immediate 'insert into new_tab values (statement_result)';
  --don`t know how and what to put as statement_result. I know that i could use cursor, but ---how in this case?
  return 1;
  
  exception
  when others then
  dbms_output.put_line(SQLERRM);
  return 0;
  
  END create_new_tab
  ;
  </code></pre>
  
  <p>Can you help me, because I give up. I have no idea how to solve this problem.
  Please help me if you can.</p>