title: ORACLE - Set the length for a varchar2 length based on a query
body: <p>I am trying to use the <code>CAST</code> function to convert the output of a column in a query, from <code>VARCHAR2</code>(255 CHAR) to <code>VARCHAR2</code> of a variable length, the final number being returned by a sub-query, like this:</p>
  
  <pre><code>SELECT CAST(Title as VARCHAR2(SELECT MAX(LENGTH(Title)) FROM Books)) 
  FROM Books;
  </code></pre>
  
  <p>Does anyone know if it is possible for me to format the output as a VARCHAR2 with the length returned by the sub query? For the example above I keep getting errors but there might be other ways.</p>