title: If condition in PL/SQL script with cursor and loop
body: <p>I would like to ask for some help or advice in this particular case.</p>
  
  <p>I have table called "Teams". The table contains 3 columns - Issue, Responsible_team and More_Info (all varchar2).</p>
  
  <p>I have a PL/SQL script with cursor and loop for selecting as many teams as issue description you type (some random word you think it might help you find the responsible team). This part works great for me. </p>
  
  <p>But I do not know how to compile the IF condition in there. If no team is found according to typed word description, I would like to get some basic output dbms_output.put_line('Responsible team is not found').
  There are 2 ways how I wrote the script. Classic loop and while loop.
  I would be happy for any advice.</p>
  
  <p>1.script</p>
  
  <pre><code>set verify off
  DECLARE
      v_issue teams.issue%type; --variable for issue column from teams table
      v_respteam teams.responsible_team%type; --variable for responsible_team column from teams table
      v_info teams.more_info%type; --variable for more_info column from teams table
  
  --cursor declaration
      CURSOR c_respteam
      RETURN teams%ROWTYPE
      IS
          SELECT issue, responsible_team, more_info
          FROM teams
          WHERE lower(issue) like '%&amp;Describe_Issue%';
  BEGIN
      OPEN c_respteam;
      LOOP
        FETCH c_respteam into v_issue, v_respteam, v_info;
        EXIT when c_respteam%NOTFOUND;
        dbms_output.put_line('Responsible team is '|| v_respteam || ' --&gt; ' || v_info);        
      END LOOP;
      CLOSE c_respteam;
  end;
  /
  </code></pre>
  
  <p>2.script</p>
  
  <pre><code>-- cursor with while loop
  set verify off
  DECLARE
      v_issue teams.issue%type; --variable for issue column from teams table
      v_respteam teams.responsible_team%type; --variable for responsible_team column from teams table
      v_info teams.more_info%type; --variable for more_info column from teams table
  
  CURSOR c_respteam
  RETURN teams%ROWTYPE IS
      SELECT issue, responsible_team, more_info
      FROM teams
      WHERE lower(issue) like '%&amp;Describe_Issue%';
  
  BEGIN
  OPEN c_respteam;
  FETCH c_respteam INTO v_issue, v_respteam, v_info;
  WHILE c_respteam%FOUND
  LOOP
  dbms_output.put_line('Responsible team is '|| v_respteam || ' --&gt; ' || v_info);
  FETCH c_respteam INTO v_issue, v_respteam, v_info;
  END LOOP;
  CLOSE c_respteam;
  END;
  /
  </code></pre>