martedì 28 gennaio 2014

Oracle: Multiple insert conditiona​l




The goal is to insert multiple lines into several lines and track the possible errors as well...



 insert all   
 when 1=1  
 then into zzz_tab_output_1 (OF1, OF2, OFK) values (IF1, IF2, IF3)  
 LOG ERRORS INTO err$_zzz_tab_output_1 (1) REJECT LIMIT UNLIMITED  
 when exists (select 1 from ZZZ_Tab_INPUT_1 where ifk in (select ofk from zzz_tab_output_1))  
 then into zzz_tab_output_2 (OF1, OF3, OFK) values (IF1, IF3, IFK)  
 LOG ERRORS INTO err$_zzz_tab_output_2 (2) REJECT LIMIT UNLIMITED  
 Select i.IF1, j.IF2, j.IF3, IFK from ZZZ_Tab_INPUT_1 i join ZZZ_Tab_INPUT_2 j using (IFK);  

Nessun commento:

Posta un commento