title: Calculating Age in Object Type FUNCTION - Oracle
body: <p>Please excuse my extremely basic understanding of SQL in Oracle. 
  I'm currently trying to have a Method in an Object Type, my attempt looks like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>CREATE TYPE Person_Type AS OBJECT
  (PersonName VARCHAR2(40),
  DateBorn DATE,
  DateDied DATE,
  MEMBER FUNCTION get_age RETURN NUMBER)</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>CREATE OR REPLACE TYPE BODY Person_Type AS
  MEMBER FUNCTION get_age RETURN NUMBER IS
  BEGIN
  *Some kind of IF DateDied NOT NULL*
  RETURN months_between(trunc(sysdate),DateBorn))/12
  END;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I cannot get the above to compile. Ultimately I want to be able to call the method and get somebodies age they are today.</p>
  
  <p>I'm able to retrieve the ages of the people currently inside my table via: 
  select months_between(TRUNC(sysdate),DateBorn)/12
  as age from person_table</p>
  
  <p>But I would like this as a callable method.</p>
  
  <p>From <em>my understanding</em>, this way of having a method within an object type would use the DateBorn form whichever row I've retrieved? I'm obviously very wrong but just need to know what the next step is and how incorrect I am at the moment...</p>
  
  <p>Thanks in advance!</p>