title: Comparing the output of 2 cursors in Oracle PL SQL
body: <p>I have 2 cursors, I would like to compare a field which is returned as the output of one cursor to another field which is also returned as the output of another cursor.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>    CREATE OR REPLACE PROCEDURE CHECK_STUDENT AS
  
          CURSOR SCHOOL_REG IS
            SELECT STUDENT_ID FROM SCHOOL WHERE CLASSROOM IN (1,2,3,4,5);
  
          CURSOR CLASS_REG IS
            SELECT STUDENT_ID, STUDENT_NAME FROM REGISTER WHERE CLASSROOM = 1;
  
          FOR X IN CLASS_REG LOOP
            IF X.STUDENT_ID &lt;&gt; SCHOOL_REG.STUDENT_ID THEN
              DBMS_OUTPUT.PUT_LINE(X.STUDENT_ID || ' IS NOT REGISTERED IN SCHOOL');
            END IF;
          END LOOP;
  
      CHECK_STUDENT END;
  </code></pre>
  
  <p>I'm not sure, how can I compare these fields. These cursors have complex queries, I have simplified for the purpose of understanding.</p>
  
  <p>Thanks in advance for your time and help.</p>