title: PLS-00201 identifier must be declared referencing user defined type as SYS
body: <p>I am having a problem with certain defined TYPEs in my package create scripts - </p>
  
  <p>I receive the following for certain TYPEs</p>
  
  <pre><code>PLS-00201 identifier must be declared 
  </code></pre>
  
  <p>For instance;</p>
  
  <pre><code>Error(7,23): PLS-00201: identifier 'another_schema.some_table_type' must be declared
  Error(8,23): PLS-00201: identifier 'another_schema.some_object_type' must be declared
  </code></pre>
  
  <p>I should note that I am changing these scripts - which ran fine before - where previously they were run as the script owner, which now is a container schema/user only - and the create scripts are being executed as SYS. (it is a dev database and they have not created a user yet for me to use to do this other than SYS so far)</p>
  
  <p>(The packages compiled previously -when run as the schema owner with appropriate privileges.)</p>
  
  <p>This package (and various other objects, views procedures and functions) access both objects in its schema owns as well as those in another schema.</p>
  
  <p>In this case - the issue is with SOME defined TYPEs (and tables of type) that are in the referenced schema - where I get the PLS-00201 error.</p>
  
  <p>In the code below, when compiling the error is generated for the references to;</p>
  
  <pre><code>      l_tc_data       another_schema.some_table_type := another_schema.some_table_type();
        l_tc_obj        another_schema.some_object_type;
  </code></pre>
  
  <p>but not;</p>
  
  <pre><code>      l_loc_t        another_schema.location_ref_t; 
  </code></pre>
  
  <p>which are in the same "other" schema.</p>
  
  <pre><code>create or replace PACKAGE BODY  example_schema.example_pkg 
  AS
  function getSomeData (p_project in varchar2, p_start_date in date, p_end_date in date, p_timezone in varchar2 := 'UTC')
  return fancydatatabletype is
        l_cursor        SYS_REFCURSOR;
        l_tsdata        fancydatatabletype := fancydatatabletype();
  
        l_tc_data       another_schema.some_table_type := another_schema.some_table_type();
        l_tc_obj        another_schema.some_object_type;
  
        t_data          fancydatatype;
        l_project       VARCHAR2(20);
        l_timezone      VARCHAR2(40);
        l_start         DATE;
        l_end           DATE;
  
        l_loc_t        another_schema.location_ref_t; 
  BEGIN
      l_tc_obj := another_schema.some_object_type(null, 1, 2, 3, 'test');
  
      -- .... more stuff
  END getSomeData;
  </code></pre>
  
  <p>So my questions are;
   1. could it possibly be an issue with privileges ? (running as SYS)
   2. what other things should I look at that could produce this error ? (since they do exist)</p>
  
  <p>I can successfully query the TYPES, so they do exist, are named the same and the user (SYS in this case) can "see" them;</p>
  
  <pre><code>select * from ALL_TYPES where type_name like 'some_table_type%';
  </code></pre>
  
  <p>I know I am being dumb, blind or just plain at the limits of my Oracle skills - so hoping someone can help me figure it out and learn for the next time !</p>