title: postgresql create function with multiple IF ELSE condition
body: <p>I am creating a function in postgresql which will do something like following:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION check_label_id_exist(_labelid integer, OUT result text) AS
  $BODY$
  DECLARE
  BEGIN
      SELECT pkid FROM table_1 WHERE label_id = _labelid;
      IF FOUND THEN
      result := 'true';
      RETURN;
      IF NOT FOUND THEN
      SELECT pkid FROM table_2 WHERE label_id = _labelid;
      IF FOUND THEN
      result := 'true';
      RETURN;
      IF NOT FOUND THEN
      SELECT pkid FROM table_3 WHERE label_id = _labelid;
      IF FOUND THEN
      result := 'true';
      RETURN;
      IF NOT FOUND THEN
      result := 'false';
  
      RETURN;
  END
  $BODY$ language plpgsql;
  </code></pre>
  
  <p>Here the function looks for data in <code>table_1</code> first. If no data then it will go to next table and so on. If any of the table has data it will break the condition and return true else finally it will return false. I think the code that I have written here is not correct. Please help to achieve my goal.</p>