title: Postgres nested if in case query
body: <p>Could you tell my why the following isnt working in postgres sql?:</p>
  
  <pre><code>See updated code below
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>I expect the query to return "0.30" as float.
  This construct is only for testing purposes, i have some complex querys which depend on this conditional structure... BUt i dont know how to fix it..</p>
  
  <p>Result is:</p>
  
  <pre><code>ERROR:  syntax error at or near "1"
  LINE 4:     if 1=1 then
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>This construction appears in a function... so I want to do following:</p>
  
  <pre><code>CREATE FUNCTION f_test(myvalue integer) RETURNS float AS $$
    BEGIN
      select (
        case (select '1')
        when '1' then
          if 1=1 then
            0.30::float
          else
            0.50::float
          end
        else
           1.00::float
        end
      );
    END;
  $$ LANGUAGE plpgsql;
  
  select f_test(1) as test;
  </code></pre>
  
  <p>Error message see above.</p>