Merge into enables the merging of existing data in an Oracle data table. Update if it is available
The following example is a test pass after the JDBC data source is connected
1. Single Data
Long Companyauthid = Seqkeyutil.getseqkey (vids, "company_auth_id"); Companyauth comtmp = companylist.get (0); String sql = "Merge into Company_auth AUTH using (select? MOBILE from dual) TMP on (auth.mobile=tmp.mobile) "+" while matched then "+" UPDATE SET auth.reserve=? " + "When not matched then" + "INSERT (id,mobile) VALUES (?,?)"; Vids.update (SQL, New Object[]{comtmp.getmobile (), Comtmp.getreserve (), companyauthid+ "", Comtmp.getmobile ()});
2. Multiple data (batch processing)
Long Companyauthid = Seqkeyutil.getseqkey (vids, "company_auth_id"),//SEQS table primary key using list<object[]> batch = new Arraylist<object[]> (); for (Companyauth company:companylist) {object[] values = new object[] {company.getmobile (), Company.getreserve (), Compan Yauthid+ "", Company.getmobile ()}; Batch.add (values); }string sql = "Merge into Company_auth AUTH using (select? MOBILE from dual) TMP on (auth.mobile=tmp.mobile) "+" while matched then "+" UPDATE SET auth.reserve=? " + "When not matched then" + "INSERT (id,mobile) VALUES (?,?)"; Vids.batchupdate (SQL, batch);
If more than one table is present, you only need to target the using (select? MOBILE from dual) TMP on modify
JDBC uses the merge into function in Oracle