title: Function returning varchar2 gives wrong result
body: <p>I want to build query dynamically as per criterias selected from gui. Here is my oracle package,</p>
  
  <pre><code>CREATE OR REPLACE PACKAGE TestPkg 
  AS
      g_lastnamelist VARCHAR2(50);
  
      FUNCTION getLastName return VARCHAR2;
      FUNCTION buildQuery(p_lastnamelist VARCHAR2);
  END;
  
  CREATE OR REPLACE PACKAGE BODY TestPkg 
  AS
  
     FUNCTION getLastName return VARCHAR2
     IS
     BEGIN
         RETURN replace(g_lastnamelist, '''', '');
     END;
  
     FUNCTION buildQuery(p_lastnamelist VARCHAR2);
     IS
         m_query varchar2(1000);
     BEGIN
         g_lastnamelist := p_lastnamelist;
         m_query := 'SELECT * FROM emp WHERE last_name IN(TestPkg.getLastName)';
     END;
  END;
  </code></pre>
  
  <p>here if i use <code>'SELECT * FROM emp WHERE last_name IN('||p_lastnamelist||')';</code> then it returns me correct record but if i use <code>'SELECT * FROM emp WHERE last_name IN(TestPkg.getLastName)';</code> like this, then it fails. Whats the reason. </p>
  
  <p>Thanks in advance.</p>