title: postgres check if null then cast to numeric
body: <p>I am trying check if a value is null if so the select null else cast to numeric, but it throws an error. This is actually part of an insert statement</p>
  
  <pre><code>INSERT into someTable(name,created,power) 
  SELECT 'xyz',now(),
  case when :power ='null' then NULL else cast(:power as numeric) end from abc 
  </code></pre>
  
  <p>error that I get is </p>
  
  <pre><code>Error: ERROR: invalid input syntax for type numeric: "null"
  </code></pre>
  
  <p>:power is a variable that can be given any value using java code. If I give a value of null it give an error.</p>
  
  <p>In code I get the following error from the java stack trace</p>
  
  <pre><code>org.postgresql.util.PSQLException: ERROR: cannot cast type bytea to numeric
  </code></pre>