title: SQL - A simpler function than decode
body: <p>I am working with a pl/sql procedure. I have an initialized variable myvar and I want to check its value : if it does not contain 'Z', I want it to contain 'P'.</p>
  
  <p>I am currently doing it this way:</p>
  
  <pre><code>myvar := decode(myvar,'Z','Z','P');
  </code></pre>
  
  <p>I was just wondering if there was a simplier way to do this. I mean, decode is already simple, but I feel it's weird to specify the content of the variable while it is already in it !</p>
  
  <p>If such a function would exist, it would look like this:</p>
  
  <pre><code>Function myfunction(a In Varchar2, b In Varchar2, c In Varchar2) 
  Return Varchar2 
  Is               
  Begin
        if a &lt;&gt; b
        then
             return c;
        end if;
        return a;
  End myfunction; 
  </code></pre>
  
  <p>Any help would be appreciated !</p>