title: PL/SQL - dbms output the result of an execute immediate
body: <p>I would like to be able to print out all results for a query (that should be filtered by the PK from TableA) and do this for each PK in TABLEA.
  This is what i have so far: </p>
  
  <pre><code> DECLARE
      CURSOR Curs IS SELECT DISTINCT PKID FROM TABLEA;
      BEGIN
      FOR rec IN Curs 
            LOOP
                EXECUTE IMMEDIATE 
                'SELECT * FROM (
                SELECT cola,
                FKTABLEA,
                colc,
                lag (cold,1) OVER (ORDER BY cold) AS cold
                FROM tableB
                WHERE FKTABLEA = :1)
                WHERE colc != cold
                order by cola' using Curs.PKID;
  
                DBMS_OUTPUT.PUT_LINE('OUTPUT ALL RESULTS FROM THE QUERY HERE');
            END LOOP;     
      END;
  </code></pre>