title: Oracle Cast using %TYPE attribute
body: <p>I want to cast a value using %TYPE attribute in my SQL statement. The %TYPE attribute lets you use the datatype of a field, record, nested table, database column, or variable in your own declarations, rather than hardcoding the type names. </p>
  
  <p>This works:</p>
  
  <pre><code>insert into t1  select cast(v as varchar2(1)) from t2;
  </code></pre>
  
  <p>But I would like to</p>
  
  <pre><code>insert into t1  select cast(v as t1.v%TYPE) from t2;
  
  Error starting at line 16 in command:
  insert into t1  select cast(v as t1.v%TYPE) from t2
  Error at Command Line:16 Column:37
  Error report:
  SQL Error: ORA-00911: Ongeldig teken.
  00911. 00000 -  "invalid character"
  *Cause:    identifiers may not start with any ASCII character other than
             letters and numbers.  $#_ are also allowed after the first
             character.  Identifiers enclosed by doublequotes may contain
             any character other than a doublequote.  Alternative quotes
             (q'#...#') cannot use spaces, tabs, or carriage returns as
             delimiters.  For all other contexts, consult the SQL Language
             Reference Manual.
  *Action:
  </code></pre>
  
  <p>Can this (or something similar) be done? </p>
  
  <p>EDIT:
  What I'm trying to achieve is: when t2.v is to large I want to truncate it. I'm trying to avoid using substr with a hard coded field length. So cast(v as t1.v%TYPE) instead of substr(v,1,1) </p>