Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

21c PL/SQL Qualified expressions PAIRS OF (sql_statement)

User_H3J7UFeb 2 2022

Documentation:
index_iterator_choice ::=
изображение.pngiterator ::=
изображение.png(iteration_ctl_seq/iteration_control) pairs_of_control ::=
изображение.pngPAIRS does not work (21.3) with sql_statement:

declare
  type tt is table of number index by varchar2(10 char);
  t tt;
begin
  t := tt(for c in (select 'one' k, 100 v from dual union all select 'two', 200 from dual) index c.k => c.v);
  for k, v in pairs of t loop
    dbms_output.put_line(k||'='||v);
  end loop;
end;
/
one=100
two=200

declare
  type tt is table of number index by varchar2(10 char);
  t tt;
begin
  t := tt(for k, v in pairs of (select 'one' k, 100 v from dual union all select 'two', 200 from dual) index k => v);
  for k, v in pairs of t loop
    dbms_output.put_line(k||'='||v);
  end loop;
end;
/
ORA-06550: line 5, column 8:
PLS-00306: wrong number or types of arguments in call to 'TT'
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored

declare
  type tt is table of number index by varchar2(10 char);
  t tt;
begin
  t := tt(for k varchar2(10 char), v number in pairs of (select 'one' k, 100 v from dual union all select 'two', 200 from dual) index k => v);
  for k, v in pairs of t loop
    dbms_output.put_line(k||'='||v);
  end loop;
end;
/
ORA-06550: line 5, column 48:
PLS-00862: The type of the iterand is not compatible with an iteration control.
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored

declare
  type tt is table of number index by varchar2(10 char);
  t tt;
begin
  t := tt(for k varchar2(10 char), v number in pairs of (execute immediate q'[select 'one' k, 100 v from dual union all select 'two', 200 from dual]') index k => v);
  for k, v in pairs of t loop
    dbms_output.put_line(k||'='||v);
  end loop;
end;
/
ORA-06550: line 5, column 11:
PLS-00801: internal error [*** ASSERT at file pdw5.c, line 1002; Unexpected type for iterand.; Xanon__0x77b4fb50__AB[5, 11]]
Comments
Post Details
Added on Feb 2 2022
3 comments
388 views