title: ORA-21700: object does not exist or is marked for delete
body: <p>I have package with Period and TableOfPeriod types:</p>
  
  <pre><code>  TYPE Period
    IS RECORD
    (   StartPeriod  Date,
        EndPeriod    Date
    );
  
    TYPE TableOfPeriod
    IS TABLE OF Period;
  </code></pre>
  
  <p>and in this package I have three simple function:</p>
  
  <pre><code>  FUNCTION Temp1
    RETURN TableOfPeriod IS
      returnedValue TableOfPeriod := TableOfPeriod();
    BEGIN
      returnedValue.extend(1);
      returnedValue(1).StartPeriod := sysdate-100;
      returnedValue(1).EndPeriod := sysdate;
      RETURN returnedValue;
    END Temp1;
  
  FUNCTION CalculateFine
    return VARCHAR2
    IS
    freewillLockTableRP         TableOfPeriod:=TableOfPeriod();
    compulsoryLockTableRP       TableOfPeriod:=TableOfPeriod();
  
    BEGIN
  
    --for testing
        compulsoryLockTableRP:=Temp1();
        FOR i IN compulsoryLockTableRP.FIRST..compulsoryLockTableRP.LAST LOOP
          IF(((compulsoryLockTableRP(i).EndPeriod - compulsoryLockTableRP(i).StartPeriod)&gt;1)) THEN
              BEGIN
  --              RAISE_APPLICATION_ERROR(-20001, 'Hello world');
                SELECT T111.StartPeriod StartPeriod,
                       T111.EndPeriod   EndPeriod
                      bulk collect into freewillLockTableFull
                FROM TABLE(DistributeDaysByPeriods(compulsoryLockTableRP, 5)) T111;
            END;
          END IF;
        END LOOP;
        /*SELECT T111.StartPeriod StartPeriod,
               T111.EndPeriod   EndPeriod
  --          BULK COLLECT INTO compulsoryLockTableRP
              bulk collect into freewillLockTableFull
        FROM TABLE(DistributeDaysByPeriods(compulsoryLockTableRP, 5)) T111;*/
    --===========
  
    --SOME OTHER PROCESSING
  
  
    RETURN 'Ok ' 
           ||  '#r';
  
  
  
  
    EXCEPTION
      WHEN No_Data_Found THEN return 'No data found#g';
  --    WHEN OTHERS THEN RETURN SQLERRM;
  
    END CalculateFine;
  </code></pre>
  
  <p>When I execute this function, I have next error:</p>
  
  <blockquote>
    <p>"ORA-21700: object does not exist or is marked for delete ORA-06512:
    at "MyPackageName", line 1181 ORA-06512: at line 1
    21700. 00000 -  "object does not exist or is marked for delete""</p>
  </blockquote>
  
  <p>where 1181 line is a line with Select statement of CalculateFine function. Can anybody tell me, whats wrong and how I can solve this problem?</p>