title: Why do I get PLS-00302: component must be declared when it exists?
body: <p>I am using Oracle 10.2.</p>
  
  <p>I am working in some scripts to move some ORACLE Objects from one SCHEMA (S1) to another (S2). 
  I am creating the functions with DBA role.
  When moved, one of my functions becomes invalid, but I don't understand why.
  Its code goes along these lines:</p>
  
  <p><strong>MY_FUNC</strong></p>
  
  <pre><code>CREATE OR REPLACE FUNCTION S2."MY_FUNC" RETURN VARCHAR2 IS
     something VARCHAR2;
     othervar VARCHAR2 (50):= 'TEST';   
  BEGIN
     something := S2.MY_FUNC2();
      /*some code*/
      return othervar;
  END;
  /
  </code></pre>
  
  <p>If I use <code>MY_FUNC2</code> without the schema, It works:<br>
  <strong><code>something := MY_FUNC2();</code></strong> instead of  <strong><code>something := S2.MY_FUNC2();</code></strong> </p>
  
  <p><strong>My_FUNC2</strong></p>
  
  <pre><code>CREATE OR REPLACE FUNCTION S2."MY_FUNC2" RETURN VARCHAR2 IS
         something BOOLEAN;
         othervar VARCHAR2 (50) := 'TEST2';           
      BEGIN
         /*some code*/
          return othervar;
      END;
      /
  </code></pre>
  
  <p>MY_FUNC2 has a synonym like this:</p>
  
  <pre><code> CREATE OR REPLACE PUBLIC SYNONYM "MY_FUNC2" FOR "S2"."MY_FUNC2"
  </code></pre>
  
  <p><code>MY_FUNC</code> compiles with errors:</p>
  
  <blockquote>
    <p>PLS-00302: component 'MY_FUNC2' must be declared</p>
  </blockquote>
  
  <p>I don't understand why I am getting this error, when my functions were in the other schema (S1) they had exactly the same structure and the synonym was created exactly the same (but pointing to S1) and <code>MY_FUNC</code> compiled fine.</p>
  
  <p>I didn't create this functions and synonym originally. Is it possible that I am missing some privileges in S2, so <code>MY_FUNC</code> can work properly?</p>