Oracle provides a convenient statement for this type action: INSERT ALL. This allows inserting rows into several tables with just one statement: (see example fiddle here)
insert all
into ord(ordernum,cnum,snum,rec,ship,typ)
values(ordernum,cnum,snum,rec,ship,typ)
into ord2(ordernum,cnum,snum,rec,ship,typ)
values(ordernum,cnum,snum,rec,ship,typ)
select ordernum,cnum,snum,rec,ship,typ
from transit;
In the above every row would be copied into both tables. This however is not required. The fiddle referenced above splits the tables between even and odd ordernum, but the split could be any on expression which eventuates true or false.
Initially my reply was just the above. But reading the comments it became apparent that OP may benefit from seeing examples of why this should be a procedure and not a function. (As could whoever required a function.)
As a developer I automatically assume a function can be called directly form SQL. In this case that is not true. This function can only be called form a plsql block. There are (at least) 2 reasons for this:
- There is no boolean data type in SQL. Boolean data type is
strictly a plsql data type.
- A function called by SQL cannot perform DML.
The referenced fiddle above also contains a example of each of these and what happens when called when called via SQL and by plsql.