title: How to assign a boolean value returned from a function to a variable in PostgreSQL 9.4?
body: <p>I have a function that checks whether a table exists on PostgreSQL or not, using the following code:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION public.sp_table_exists(p_in_table_name character varying)
    RETURNS boolean AS
  $$
      DECLARE QUERY_COUNT INTEGER DEFAULT 1;
      QUERY_STRING VARCHAR(300);
      BEGIN
          QUERY_STRING := CONCAT('SELECT RELNAME FROM PG_CLASS WHERE RELNAME = ''',p_in_table_name,'''');
          EXECUTE QUERY_STRING;
          GET DIAGNOSTICS QUERY_COUNT = ROW_COUNT;
          IF QUERY_COUNT &gt; 0  THEN
              RETURN TRUE;
          ELSE
              RETURN FALSE;
          END IF;     
      END;
  $$ LANGUAGE plpgsql;
  </code></pre>
  
  <p>I'm trying to use the output of the above function to assign to a boolean value, but PostgreSQL doesn't allow me to do so.</p>
  
  <pre><code>DECLARE DEBUG_ENABLED boolean DEFAULT FALSE;
  DEBUG_ENABLED := PERFORM sp_table_exists('temp_table');
  </code></pre>
  
  <p><strong>OR</strong></p>
  
  <pre><code>DEBUG_ENABLED := SELECT * FROM sp_table_exists('temp_table');
  </code></pre>
  
  <p>Can you please help me resolve this?</p>