title: Why ORACLE TO_DATE function does not gives an ORA-01841 error in OR condition when spaces gets passed?
body: <pre><code>SQL&gt; select to_date('    ','YYYYMMDD') from dual;
  ERROR at line 1:
  ORA-01841: (full) year must be between -4713 and +9999, not be 0
  
  SQL&gt; select * from dual where to_date('    ','YYYYMMDD') = '19960512' or 1 = 2;
  ERROR at line 1:
  ORA-01841: (full) year must be between -4713 and +9999, not be 0
  
  SQL&gt; select * from dual where to_date('    ','YYYYMMDD') = '19960512' or 1 = 1;
  Success.
  </code></pre>
  
  <p>In first two statements we are passing spaces to TO_DATE function which gives an error which is expected.
  But</p>
  
  <p><strong>Now in third statement we are passing spaces to TO_DATE oracle function which is not allowed. But still it executes successfully.</strong></p>
  
  <p>Why?</p>
  
  <p>In actual code I might pass spaces from variable and OR part may or may not be true.</p>
  
  <p><strong>Can anyone explain me this behaviour and how to handle to get an error?</strong></p>
  
  <p><em>P.S - I am on Oracle 12g EE</em></p>