Is there a way to automate the copying of common attributes from one record to another?
I'm looking for a way to not manually touch the "automate_this_block" section of code every time I evolve TableA/TableB and Some_View.
Why? As any programmer would say: Pure laziness.
-- sample VIEW
create or replace
view some_view
as
select a.a_id, b.b_id, a.a_meta_1, a.a_meta_2, b.b_meta_1, b.b_meta2
from TableA a
join TableB b on a.a_id=b.a_id;
-- sample API
create or replace
procedure ins_some_view( rcd in some_view%rowtype )
as
rcd_a TableA%rowtype;
rcd_b TableB%rowtype;
b_id TableB.b_id%type;
begin
<<automate_this_block>>
begin
-- copy all attributes common between TableA and Some_View to rcd_a
rcd_a.a_meta_1 := rcd.a_meta_1;
rcd_a.a_meta_2 := rcd.a_meta_2;
-- etc
-- copy all attributes common between TableB and Some_View to rcd_b
rcd_b.b_meta_1 := rcd.b_meta_1;
rcd_b.b_meta_2 := rcd.b_meta_2;
-- etc
end;
-- lots-o-stuff goes here
-- set DEFAULTS (including VPD column(s) )
-- apply custom calculations (if needed)
-- application validations/assertions (pre-DML)
-- other stuff that can't be done in a table-definition.
-- do the actual CRUD work
insert into TableA
values rcd_a
returning A_id into rcd_b.a_id;
insert into TableB
values rcd_b;
end;
/