title: Oracle and optional stored procedure parameter in where clause
body: <p>I have a stored procedure with an optional parameter like this</p>
  
  <pre><code>create or replace 
  PROCEDURE "my_stored_procedure" (param1 int, param2 int default null)
  IS
  
  BEGIN 
  
  [select some fields from some tables]
  ...
  </code></pre>
  
  <p>I need a <code>where</code> clause with a if on the default parameter (if it is set), but I don't even know if it's possible...</p>
  
  <p>Something like</p>
  
  <pre><code>where param1=123 and (if param2 is not null then some_value != param2)
  </code></pre>
  
  <p>The <code>select</code> clause it's pretty long and complex, so I'll prefer to have a "flexible" <code>WHERE</code> rather than a structure like</p>
  
  <pre><code>if param2 is not null then
      [long and complex select] where param1=123 and some_value != param2
  else
      [long and complex select] where param1=123
  </code></pre>
  
  <p>Is this possible?</p>