Merge data into table in Oracle

If you need to merge some data into one table you want by replacing manual inserting with ' merge into ' operation, maybe the following code is what you want. You can use it to make u get more efficient. Pls follow steps to operate.

 

 

1.create table that you want to insert data into it or create it in the following script test.sql.

--test.sql

set serveroutput on;
spool insert.log
drop table properties;
create table properties (identifier varchar2(4000), value varchar2(4000));

@query_properties_insert_jeff.sql;
show errors;

spool off

 
2.create the below script query_properties_insert_jeff.sql, and run it to merge data like query sentences or other data into the above table

--query_properties_insert_jeff.sql

--table name: properties, this table have two cloumns, identifier and value like key-value
merge into properties p
  using (select 'getSalesCCIDfromAcctRowIdReq' identifier, 'select PARTY_SALES.SALES_CCID from CCI.PARTY_SALES where PARTY_SALES.Siebel_Row_Id = ?' value from dual) s
  on (p.identifier = s.identifier)
 when matched then update set p.value = s.value
 when not matched then insert (identifier, value) values (s.identifier, s.value);



merge into properties p
  using (select 'GCSM_TIMEOUT' identifier, 6000 value from dual) s
  on (p.identifier = s.identifier)
 when matched then update set p.value = s.value
 when not matched then insert (identifier, value) values (s.identifier, s.value);

 

转载于:https://www.cnblogs.com/Jeffrey-xu/p/4977922.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值