drop table my_parts
ORA-00942: table or view does not existMore Details: https://docs.oracle.com/error-help/db/ora-00942
create table my_parts (partnum number, partname varchar2 (100), quantity_sold number(2))
Table created.
drop type my_parts_nt force
ORA-04043: object MY_PARTS_NT does not existMore Details: https://docs.oracle.com/error-help/db/ora-04043
drop type my_parts_ot force
ORA-04043: object MY_PARTS_OT does not existMore Details: https://docs.oracle.com/error-help/db/ora-04043
create or replace type my_parts_ot authid definer is object
(partnum number, partname varchar2 (100), quantity_sold number(20))
Type created.
create or replace type my_parts_nt is table of my_parts_ot;
Type created.
begin
for i in 1..99 loop
insert into my_parts values (
i,
'part ' || i,
i
);
end loop;
commit;
end;
Statement processed.
create or replace procedure show_count
authid definer
is
n number;
begin
select count(*)
into n
from my_parts;
dbms_output.put_line('rows in my_parts: ' || n);
end;
Procedure created.
create or replace procedure insert_n (
p_n in number
)
authid definer
is
begin
show_count;
insert into my_parts (
partnum,
partname,
quantity_sold
)
select partnum * partnum,
'new ' || partname,
partnum + partnum
from my_parts
where partnum <= p_n and partname not like 'new%';
dbms_output.put_line('inserted '
|| sql%rowcount
|| ' rows');
show_count;
exception
when others then
dbms_output.put_line('ERROR!');
dbms_output.put_line('inserted '
|| sql%rowcount
|| ' rows');
show_count;
dbms_output.put_line('error: ' || sqlerrm);
end;
Procedure created.
begin
insert_n(10);
insert_n(49);
insert_n(50);
insert_n(100);
rollback;
end;
Statement processed.
rows in my_parts: 99
inserted 10 rows
rows in my_parts: 109
rows in my_parts: 109
inserted 49 rows
rows in my_parts: 158
rows in my_parts: 158
ERROR!
inserted 49 rows
rows in my_parts: 158
error: ORA-01438: value larger than specified precision allowed for this column
rows in my_parts: 158
ERROR!
inserted 49 rows
rows in my_parts: 158
error: ORA-01438: value larger than specified precision allowed for this column
create or replace procedure insert_n_forall (
p_n in number
)
authid definer
is
l_parts my_parts_nt;
begin
select my_parts_ot (partnum * partnum,
'new ' || partname,
partnum + partnum)
bulk collect
into l_parts
from my_parts
where partnum <= p_n
and partname not like 'new%';
forall indx in 1..l_parts.count
save exceptions
insert into my_parts (
partnum,
partname,
quantity_sold
) values (
l_parts(indx).partnum,
l_parts(indx).partname,
l_parts(indx).quantity_sold
);
dbms_output.put_line('inserted '
|| sql%rowcount
|| ' rows');
show_count;
exception
when others then
dbms_output.put_line('ERROR! ' );
dbms_output.put_line('inserted '
|| sql%rowcount
|| ' rows');
show_count;
dbms_output.put_line('error: ' || sqlerrm);
end;
Procedure created.
begin
insert_n_forall(10);
insert_n_forall(49);
insert_n_forall(50);
insert_n_forall(100);
rollback;
end;
Statement processed.
inserted 10 rows
rows in my_parts: 109
inserted 49 rows
rows in my_parts: 158
ERROR!
inserted 49 rows
rows in my_parts: 207
error: ORA-24381: error(s) in array DML
ERROR!
inserted 49 rows
rows in my_parts: 256
error: ORA-24381: error(s) in array DML