Guest_imported
New member
- Jan 1, 1970
- 0
Hi,
I have 8 tables, each of which has data that needs to be manipulated and consolidated into 1 table.
My approach is (and has to be) like this:
******************************************
create or replace package body XMB_MIS is
PROCEDURE test
(
p_type IN varchar2,
)
IS
cursor cur_One is
select
... as myField1
... as myField2
... as myField3
from
tblOne;
cursor cur_Two is
select
... as myField1
... as myField2
... as myField3
from
tblTwo;
--etc
cursor cur_Eight is
select
... as myField1
... as myField2
... as myField3
from
tblEight;
BEGIN
if p_type = 'One' then
open cur_One;
elsif p_type = 'Two' then
open cur_Two;
end if
'stuck here
for rec in cur_One
loop
begin
insert into myNewtable
(
myField1,
myField2,
myField3...
)
values
(
rec.myField1,
rec.myField2,
rec.myField3,
);
end;
end loop;
commit;
end;
*****************************
So, I'd like to reuse the INSERT statement.
The parameter p_type passed to the function would determine the cursor to be used in the single INSERT statement.
Any ideas/suggestions?
Cheers
I have 8 tables, each of which has data that needs to be manipulated and consolidated into 1 table.
My approach is (and has to be) like this:
******************************************
create or replace package body XMB_MIS is
PROCEDURE test
(
p_type IN varchar2,
)
IS
cursor cur_One is
select
... as myField1
... as myField2
... as myField3
from
tblOne;
cursor cur_Two is
select
... as myField1
... as myField2
... as myField3
from
tblTwo;
--etc
cursor cur_Eight is
select
... as myField1
... as myField2
... as myField3
from
tblEight;
BEGIN
if p_type = 'One' then
open cur_One;
elsif p_type = 'Two' then
open cur_Two;
end if
'stuck here
for rec in cur_One
loop
begin
insert into myNewtable
(
myField1,
myField2,
myField3...
)
values
(
rec.myField1,
rec.myField2,
rec.myField3,
);
end;
end loop;
commit;
end;
*****************************
So, I'd like to reuse the INSERT statement.
The parameter p_type passed to the function would determine the cursor to be used in the single INSERT statement.
Any ideas/suggestions?
Cheers