title: Oracle PL/SQL Functions: "Invalid Datatype"
body: <p>The following function checks to see if a zip code is present in a table called ZIPCODE: </p>
  
  <pre><code>create or replace function zip_does_not_exist(i_zip in zipcode.zip%type)
  return boolean
  as
  v_zip zipcode.zip%type;
  begin
  select zip into v_zip
  from zipcode
  where zip = i_zip;
  if v_zip is not null then
  return false;
  else
  return true;
  end if;
  end;
  /
  </code></pre>
  
  <p>The schema for the ZIPCODE table is as follows: 
  <a href="https://i.stack.imgur.com/x2Pnd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x2Pnd.png" alt="ZIPCODE"></a></p>
  
  <p>To test this function, I issued the following statement which should return false as the zip code passed as an argument is present in the ZIPCODE table:</p>
  
  <pre><code>select zip_does_not_exist('00914') from dual;
  </code></pre>
  
  <p>However, I receive this message when trying to run this code: </p>
  
  <pre><code>Error report:
  SQL Error: ORA-00902: invalid datatype
  00902. 00000 -  "invalid datatype"
  *Cause:    
  *Action:
  </code></pre>
  
  <p>This should not be happening, as '00914' is the proper datatype needed as an argument (varchar2(5)). Why am I receiving this message? </p>