title: PostgreSQL 9.3: isnumeric() in a condition
body: <p>I need to check whether the given text is numeric or not from the 
  function.</p>
  
  <p>Creating function for <code>isnumeric()</code>:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION isnumeric(text) RETURNS BOOLEAN AS $$
  DECLARE x NUMERIC;
  BEGIN
      x = $1::NUMERIC;
      RETURN TRUE;
  EXCEPTION WHEN others THEN
      RETURN FALSE;
  END;
  $$ LANGUAGE plpgsql IMMUTABLE;
  </code></pre>
  
  <p>Function from which I am calling the <code>isnumeric()</code> function:</p>
  
  <pre><code>create or replace function tm(var text)
  returns varchar as
  $$
  begin
      if (select isnumeric(var))=t::BOOLEAN then
          raise info 'Is numeric value';
      else
          raise info 'Not numeric';
      end if;
  end;
  $$
  language plpgsql;
  </code></pre>
  
  <p>Calling functon:</p>
  
  <pre><code>select tm('1');
  </code></pre>
  
  <p>Getting an error:</p>
  
  <p>Here is the error details:</p>
  
  <pre><code>ERROR:  column "t" does not exist
  LINE 1: SELECT (select isnumeric(var))=t::BOOLEAN
  </code></pre>