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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

forall insert condition

siegwin.portJan 17 2025

Hi

I try to insert an bulk collection and use thw when clause:

create table ort_rest as select * from dept where 1=2;
create table ort_10 as select * from dept where 1=2;

declare
type ort_rec is table of dept%rowtype index by pls_integer;
ort_tab ort_rec;
begin
select * bulk collect into ort_tab from dept;
forall i in ort_tab.first .. ort_tab.last
insert
WHEN ort_tab(i).deptno = 10 THEN
INTO ort_10
VALUES (
ort_tab(i).deptno,
ort_tab(i).dname,
ort_tab(i).loc
)
ELSE
INTO ort_rest
VALUES (
ort_tab(i).deptno,
ort_tab(i).dname,
ort_tab(i).loc
)
select deptno,dname,loc from table(ort_tab);
commit;
end;
I get the error

Fehlerbericht -
ORA-06550: Zeile 22, Spalte 40:
PLS-00382: Dieser Ausdruck hat den falschen Typ
ORA-06550: Zeile 22, Spalte 34:
PL/SQL: ORA-22905: Zugriff auf Zeilen eines Objekts, das keine Nested Table ist, nicht möglich
ORA-06550: Zeile 7, Spalte 1:
PL/SQL: SQL Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.

Please help me

Regards

Siegwin

This post has been answered by James Su on Jan 17 2025
Jump to Answer

Comments

Post Details

Added on Jan 17 2025
3 comments
163 views