using (select orunId as orun_id, clientId as client_id, clientAppName as client_app_name, origin as origin, redirectUri as redirect_uri from dual) src on (trgt.client_app_name = src.client_app_name and trgt.orun_id = src.orun_id) when matched then update set client_id = src.client_id, origin = src.origin, redirect_uri = src.redirect_uri when not matched then insert (id, orun_id, client_id, client_app_name, origin, redirect_uri) values (CS_ORUR_ID.Nextval, src.orun_id, src.client_id, src.client_app_name, src.origin, src.redirect_uri);
merge into C_ORUR_API_SCOPES trgt
using (select apsc.id as apsc_id, orur.id as orur_id from C_API_SCOPES apsc join c_origin_urls orur on orur.orun_id = apsc.orun_id and orur.client_id = clientId ) src on (trgt.apsc_id = src.apsc_id and trgt.orur_id = src.orur_id) when not matched then insert (ID,APSC_ID, ORUR_ID, WRITE_ALLOWED) values (CS_ORAS_ID.nextval, src.apsc_id, src.orur_id, 1);
Microsoft Access Guide to Success: From Fundamentals to Mastery in Crafting Databases, Optimizing Tasks, & Making Unparalleled Impressions [III EDITION]