title: PLS-00103: Encountered the symbol "end-of-file" when expecting error
body: <p>I am not a DB person, I am trying to run a SQL script provided to me, which throws the below error. Can someone please let me know how to fix it. Thanks in advance</p>
  
  <pre><code>[6550] ORA-06550: line 27, column 10:
  PLS-00103: Encountered the symbol "end-of-file" when expecting one of the 
  following:
  
     begin function pragma procedure
  </code></pre>
  
  <p>I am running this on Oracle v12.1, let me know if you need any other information.</p>
  
  <p>Also, I tried executing the same on v12.2 intance, but still get the same error.</p>
  
  <p>Here is the SQL that I am executing</p>
  
  <pre><code>DECLARE 
     type ah_cursor IS REF CURSOR;
     ah_cur ah_cursor;
     ah_unmatched_cur ah_cursor;
     PROCEDURE insertAHFromCursor(cur IN ah_cursor) 
          IS 
          type ah_row is record("ISSUE_ID" NUMBER(38,0),
          "SEQNUMBER" NUMBER(38,0),
          "ATTRGUID" VARCHAR2(255 BYTE),
          "AUDITTIME" NUMBER(19,0),
          "PROJECTVERSION_ID" NUMBER(38,0),
          "USERNAME" VARCHAR2(255 BYTE),
          "CONFLICT" CHAR(1 BYTE) DEFAULT 'N',
          "OLDVALUE" VARCHAR2(500 BYTE),
          "NEWVALUE" VARCHAR2(500 BYTE));
          type TObjectTable is table of ah_row;
          ObjectTable$ TObjectTable;
        BEGIN
          LOOP
          fetch cur BULK COLLECT INTO ObjectTable$ LIMIT 1000;
          EXIT WHEN ObjectTable$.COUNT &lt; 1;
          forall x in ObjectTable$.First..ObjectTable$.Last
          insert into audithistory(issue_id, seqNumber, attrGuid, auditTime, projectVersion_id, userName, conflict, oldValue, newValue)
          values (ObjectTable$(x).issue_id, ObjectTable$(x).seqNumber, ObjectTable$(x).attrGuid, ObjectTable$(x).auditTime, ObjectTable$(x).projectVersion_id, ObjectTable$(x).userName,  ObjectTable$(x).conflict, ObjectTable$(x).oldValue, ObjectTable$(x).newValue);
          commit;
          END LOOP;
        END;
  
        BEGIN
          OPEN ah_cur FOR
            SELECT aho.issue_id issue_id, aho.seqNumber seqNumber, aho.attrGuid attrGuid, aho.auditTime auditTime, 
              aho.projectVersion_id projectVersion_id, aho.userName userName, aho.conflict conflict,
              (CASE WHEN aho.oldValue IS NULL THEN 'NULL'
                  WHEN alOld.lookupValue IS NULL THEN CAST(aho.oldValue as varchar2(500))
                  ELSE CAST(alOld.lookupValue as varchar2(500)) END) oldValue,
              (CASE WHEN aho.newValue IS NULL THEN 'NULL'
                  WHEN alNew.lookupValue IS NULL THEN CAST(aho.newValue as varchar2(500))
                  ELSE CAST(alNew.lookupValue as varchar2(500)) END) newValue
          FROM audithistory_old aho
              INNER JOIN attr a ON aho.attrGuid = a.guid
              LEFT JOIN attrlookup alNew ON alNew.attrGuid = aho.attrGuid AND aho.newValue = alNew.lookupIndex
              LEFT JOIN attrlookup alOld ON alOld.attrGuid = aho.attrGuid AND aho.oldValue = alOld.lookupIndex
          WHERE a.attrType = 'CUSTOM'   
      insertAHFromCursor(ah_cur);
      close ah_cur;
      open ah_unmatched_cur for
          SELECT aho.issue_id issue_id, aho.seqNumber seqNumber, aho.attrGuid attrGuid, aho.auditTime auditTime, 
              aho.projectVersion_id projectVersion_id, aho.userName userName, aho.conflict conflict,
              (CASE WHEN aho.oldValue IS NULL THEN NULL ELSE CAST(aho.oldValue AS varchar2(500)) END) oldValue,
              (CASE WHEN aho.newValue IS NULL THEN NULL ELSE CAST(aho.newValue AS varchar2(500)) END) newValue
          FROM audithistory_old aho 
          WHERE NOT EXISTS (SELECT 1 
              FROM audithistory ah 
              WHERE aho.issue_id = ah.issue_id AND aho.seqNumber = ah.seqNumber);
       insertAHFromCursor(ah_unmatched_cur);
      close ah_unmatched_cur;
  END;
  /
  </code></pre>