title: PLS-00123: program too large (Diana nodes) while trying to compile a package
body: <p>While compiling a package, I ran into an error message:</p>
  
  <pre><code>Error: PLS-00123: program too large (Diana nodes)
  Line: 1
  </code></pre>
  
  <p>The package in question has about 1k lines (spec) + 13k lines in body. While researching on this, I came across <a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:571023051648" rel="noreferrer">this Ask Tom question</a></p>
  
  <blockquote>
    <p>When compiling a PL/SQL unit, the
    compiler builds a parse tree.  The 
    maximum size of a  PL/SQL unit is
    determined by the size of the parse
    tree.  A maximum number of diana nodes
    exists in this tree.</p>
    
    <p>Up to 7.3, you could have <code>2**14</code> (16K)
    diana nodes, and from 8.0 to 8.1.3,
    <code>2**15</code> (32K)  diana nodes were allowed.
    With 8.1.3, this limit has been
    relaxed so that you can now  have
    <code>2**26</code> (i.e., 64M) diana nodes in this
    tree for package and type bodies.</p>
    
    <p>While there is no easy way to
    translate the limits in terms of lines
    of source code, it  has been our
    observation that there have been
    approximately 5 to 10 nodes per line
    of  source code.  Prior to 8.1.3, the
    compiler could cleanly compile up to
    about 3,000 lines  of code.<br>
    Starting with 8.1.3, the limit was
    relaxed for package bodies and type
    bodies which can  now have
    approximately up to about 6,000,000
    lines of code.</p>
    
    <p>This is a rough estimate.  If your
    code has many spaces, long
    identifiers, etc., you may  end up
    with source code larger than this.</p>
  </blockquote>
  
  <p>Now even if you take into consideration the last list about many spaces &amp; large identifiers, I think it's reasonable to conclude that it's no where close the limits referred above.</p>
  
  <p>Further more,</p>
  
  <blockquote>
    <p>How to Check the Current Size of a package:</p>
    
    <p>To check the size of a package, the
    closest related number you can use is
    PARSED_SIZE in  the data dictionary
    view USER_OBJECT_SIZE.  This value
    provides the size of the DIANA in 
    bytes as stored in the <code>SYS.IDL_xxx$</code>
    tables and is NOT the size in the
    shared pool.  </p>
    
    <p>[...] </p>
    
    <p>For example, you may begin
    experiencing problems with a 64K limit
    when the <code>PARSED_SIZE</code> in 
    <code>USER_OBJECT_SIZE</code> is no more than 50K.</p>
  </blockquote>
  
  <p>Querying this view gives a result of <code>48929</code> - so I assume it's fair to size is 47k ?</p>
  
  <p>The weird part is, fetching the same object from another schema and running it in the area I'm having problem results in successful compilation. </p>
  
  <p>So why is this particular area causing problem ?</p>