Oracle Create Function
<p>I tried to create an Oracle function where table name, column name and where string are dynamic parameters:</p>

<pre><code>CREATE OR REPLACE FUNCTION MYSCHEMA.myFunctionName( 
  tableName in nvarchar2,
  columnName in nvarchar2,
  whereStr in nvarchar2)
RETURN nvarchar2

IS nActive nvarchar2(2000);

BEGIN
  declare 
  querystr nvarchar2(2000) ;
  result nvarchar2(2000);
  begin
    querystr :='
    select  listagg('+columnName+','+','+') within group (order by '+columnName+')
    from '+tableName+' where  1 = 1 '+whereStr+';';
    EXECUTE IMMEDIATE querystr
    INTO result;
       nActive := result;
          RETURN ( nActive );
  end;
END ;
/
</code></pre>

<p>But it gives me error "Warning: compiled but with compilation errors".</p>

<p>What am I doing wrong?</p>