title: How to use NVL in where clause
body: <p>I have the following code:</p>
  
  <pre><code>SELECT cr_ts, msg_id, info 
  FROM messaging_log
  WHERE UPPER(INFO) LIKE '%' || TRIM(UPPER(P_INFO)) || '%'
  AND cr_ts &gt;= NVL(P_DATE, SYSDATE-10)
  AND msg_id = NVL(P_ID, msg_id)
  ORDER BY cr_ts desc;
  </code></pre>
  
  <p>where P_INFO, P_DATE and P_ID are parameters. In the normal case every parameter is NULL. But then the where clause <code>AND msg_id = NVL(P_ID, msg_ID)</code> don't return the rows where msg_id itself is NULL. What did I miss?</p>
  
  <p>How to return all entries when P_ID and msg_id are NULL?</p>