title: How to transform the index in a integer in a forall loop?
body: <pre><code>CREATE TYPE o_A AS OBJECT (A1 VARCHAR2 (4000));
  
  CREATE OR REPLACE TYPE t_A IS TABLE OF o_A;
  
  CREATE TABLE table_o_A
  (
        oA_id                INTEGER GENERATED BY DEFAULT AS IDENTITY,
        oA                   o_A,
        PRIMARY KEY (oA_id)
      );
  </code></pre>
  <p>I would to add the lines of a t_A in the table_oA.</p>
  <pre><code>CREATE PROCEDURE aa (query_result    t_A)
  is
      v_i   INTEGER;
  begin
      SELECT MAX (oA_id)
            INTO v_i
            FROM table_o_A;
            
      FORALL i IN INDICES OF query_result
              INSERT INTO table_o_A(
                              oA_id,
                              oA)
                   VALUES ( v_i+i, query_result (i));
                   
  end;
  </code></pre>
  <blockquote>
  <p>[Error] Compilation (887: 26): PLS-00430: FORALL iteration variable I is not allowed in this context</p>
  </blockquote>
  <p>I thinks it doesn't work because i isn't an integer.
  I could use a for loop and use a real integer but it make a switch between the pl/sql and sql context.
  How do I do that with the ForAll loop?</p>
  <p><a href="https://dbfiddle.uk/?rdbms=oracle_21&amp;fiddle=48f7175db930b9abd1e416ae3faba313" rel="nofollow noreferrer">code</a></p>
  <p><a href="https://dbfiddle.uk/?rdbms=oracle_21&amp;fiddle=b159c2b5e9b554bf174191b57c92c99e" rel="nofollow noreferrer">solution from Alex Poole</a></p>