title: Postgres Raise warning if count is 0
body: <p>I am very new to postgres and i need to truncate table if there is any record otherwise I need to raise WARNING .I am trying to do the following :</p>
  
  <pre><code>BEGIN
      TRUNCATE TABLE public."BINARY";
  EXCEPTION
      WHEN SELECT COUNT(*) FROM  public."BINARY" THEN RAISE NOTICE 'There is no record present in table.';
  END;
  </code></pre>
  
  <p>But the above code is not working.Can anyone please suggest me ,what I am doing wrong ?</p>