title: ORA-06502: Numeric or Value Error on very basic string function, what gives?
body: <p>Here's the code... this isn't the complete code. I trimmed it down to where the first error occurred:</p>
  
  <pre><code> FUNCTION get (  
      p_sql_o                         OUT VARCHAR2
    ) RETURN VARCHAR2 AS
    str_sql           VARCHAR2(4000);
    BEGIN
      str_sql := ' SELECT * FROM ( SELECT A.*, ROWNUM RNUM FROM ( ' ||
                 ' SELECT item_code, ' ||
                 ' item_desc, ' ||
                 ' monitor, ' ||
                 ' measured, ' ||
                 ' inventory, ' ||
                 ' (measured - inventory) adj_amount, ' ||
                 ' (inventory_cost * measured) measured_cost, ' ||
                 'inventory';
      RETURN str_sql;
    EXCEPTION
      WHEN OTHERS THEN
      RETURN NULL;
    END get;
  </code></pre>
  
  <p>Obviously, the SQL is incomplete, but I'm not running it. I'm simply returning the SQL string, yet I still get an error:</p>
  
  <p>ORA-06502: PL/SQL: numeric or value error: character string buffer too small
  ORA-06512: at line 6</p>
  
  <p>This is baffling. Does anyone have any clue as to why this would be the case?</p>