저장 프로세스 대량 수정
7085 단어 저장 프로세스 매개 변수 대량
긴 말 없이 바로 코드를 붙이다
유형 생성:
drop type irms_type_ma_table;
drop type irms_type_ma ;
create or replace type irms_type_ma as object (
user_order_id varchar2(20),
in_res_attribute_code varchar2(50),
res_value varchar2(50),
req_user varchar2(20),
req_date varchar2(20),
op_user varchar2(20)
);
CREATE OR REPLACE TYPE irms_type_ma_table AS table OF irms_type_ma ;
스토리지 프로세스 생성:
create or replace procedure proc_modifyattribute(params in irms_type_ma_table,outp out varchar2)
as
tmp_user_order_id varchar2(20); -- user_order_id
tmp_in_res_attribute_code varchar2(50); -- in_res_attribute_code
tmp_res_table_column_value varchar2(50); -- tmp_res_table_column_value
tmp_product_id rt_UserOrder_info.product_id%type;
tmp_net_type_id rt_UserOrder_info.net_type_id%type;
tmp_in_busi_res_kind_code rt_ResReturnConfig_dict.in_busi_res_kind_code%type;
tmp_in_atom_res_value rt_ResReturnConfig_dict.in_atom_res_value%type;
tmp_in_res_table rt_ResReturnConfig_dict.in_res_table%type;
tmp_in_res_table_pk rt_ResReturnConfig_dict.in_res_table_pk%type;
tmp_in_res_table_column rt_ResReturnConfig_dict.in_res_table_column%type;
tmp_res_id rt_WorkRes_info.res_id%type;
tmp_atom_res_kind_code rt_WorkAtomRes_info.atom_res_kind_code%type;
tmp_value rt_WorkAtomRes_info.value1%type; --
tmp_sql varchar2(1000);
cursor curs is select * from the (
select cast (params as irms_type_ma_table) from dual
);
begin
for cur in curs loop
--
tmp_user_order_id := cur.user_order_id ;
tmp_in_res_attribute_code := cur.in_res_attribute_code;
tmp_res_table_column_value := cur.res_value;
outp := tmp_user_order_id;
--1. ID(product_id)、 (net_type_id)
dbms_output.put_line('1. ID(tmp_product_id)、 (tmp_net_type_id)');
dbms_output.put_line('start...');
select
userorder_info.product_id,userorder_info.net_type_id into tmp_product_id,tmp_net_type_id
from
rt_UserOrder_info userorder_info
where
userorder_info.user_order_id = tmp_user_order_id;
dbms_output.put_line(' --->'||tmp_product_id);
dbms_output.put_line(' --->'||tmp_net_type_id);
dbms_output.put_line('end...');
dbms_output.put_line('');
/*2. ID(tmp_product_id)、 (tmp_net_type_id)、 (tmp_in_res_attribute_code)
(tmp_in_busi_res_kind_code)、 value (tmp_in_atom_res_value)、 (tmp_in_res_table)、
(tmp_in_res_table_pk)、 (tmp_in_res_table_column)*/
dbms_output.put_line('2. ID(tmp_product_id)、 (tmp_net_type_id)、 (tmp_in_res_attribute_code)
(tmp_in_busi_res_kind_code)、 value (tmp_in_atom_res_value)、 (tmp_in_res_table)、
(tmp_in_res_table_pk)、 (tmp_in_res_table_column)');
dbms_output.put_line('start...');
select
rrcd.in_busi_res_kind_code,
rrcd.in_atom_res_value,
rrcd.in_res_table,
rrcd.in_res_table_pk,
rrcd.in_res_table_column
into
tmp_in_busi_res_kind_code,
tmp_in_atom_res_value,
tmp_in_res_table,
tmp_in_res_table_pk,
tmp_in_res_table_column
from
rt_ResReturnConfig_dict rrcd
where
rrcd.product_id = tmp_product_id and
rrcd.net_type_code = tmp_net_type_id and
rrcd.in_res_attribute_code = tmp_in_res_attribute_code;
dbms_output.put_line(' --->'||tmp_in_busi_res_kind_code);
dbms_output.put_line(' value --->'||tmp_in_atom_res_value);
dbms_output.put_line(' --->'||tmp_in_res_table);
dbms_output.put_line(' --->'||tmp_in_res_table_pk);
dbms_output.put_line(' --->'||tmp_in_res_table_column);
dbms_output.put_line('end...');
dbms_output.put_line('');
/*3. (tmp_user_order_id) (tmp_in_busi_res_kind_code) ID(tmp_res_id)*/
dbms_output.put_line('3. (tmp_user_order_id) (tmp_in_busi_res_kind_code) ID(tmp_res_id)');
dbms_output.put_line('start...');
select
wri.res_id into tmp_res_id
from
rt_WorkRes_info wri
where
wri.user_order_id=tmp_user_order_id and
wri.res_kind_code=tmp_in_busi_res_kind_code;
dbms_output.put_line(' ID --->'||tmp_res_id);
dbms_output.put_line('end...');
dbms_output.put_line('');
/*4. ID(tmp_res_id), (tmp_atom_res_kind_code)、 */
dbms_output.put_line('4. ID(tmp_res_id), (tmp_atom_res_kind_code)、 ');
dbms_output.put_line('start...');
tmp_sql := 'select wari.atom_res_kind_code,wari.'||tmp_in_atom_res_value||' from rt_WorkAtomRes_info wari where wari.res_id=:1';
execute immediate tmp_sql into tmp_atom_res_kind_code,tmp_value using tmp_res_id ;
dbms_output.put_line(' --->'||tmp_atom_res_kind_code);
dbms_output.put_line(' value --->'||tmp_value);
dbms_output.put_line('end...');
dbms_output.put_line('');
/*5. */
dbms_output.put_line('5. ');
dbms_output.put_line('start...');
tmp_sql := 'update '||tmp_in_res_table||' set '||tmp_in_res_table_column||'=:1 where '||tmp_in_res_table_pk||'=:2';
execute immediate tmp_sql using tmp_res_table_column_value,tmp_value ;
dbms_output.put_line(' !');
dbms_output.put_line(' --->'||tmp_res_table_column_value);
dbms_output.put_line('end...');
dbms_output.put_line('');
end loop;
commit;
exception
when others then
outp := SQLERRM ;
dbms_output.put_line(' !'||SQLERRM);
end;