dynamic oracle sql parent-child cursor insert -
i'd insert values parent table_1 , child table_2 tables in cursor. how can that? if statement , variables trying.
all columns constraint: table_1 constraints: pprt_mandant_nr, pprt_pro_prod_nr, pprt_prp_position table_2 constraints: patt_mandant_nr, patt_pro_prod_nr, patt_prp_position, patt_are_realartnr
this code working without error message wrong results. few rows table_2. think if statement wrong. or dunno... me pls.
open l_cursor l_query; fetch l_cursor bulk collect l_sucherg; close l_cursor; := l_sucherg.first; while not null loop if ( l_pro_mandant_nr <> l_sucherg (i).pro_mandant_nr or l_pro_prod_nr <> l_sucherg (i).pro_prod_nr or l_prp_position <> l_sucherg (i).prp_position) , l_prp_are_realartnr <> l_sucherg (i).prp_are_realartnr begin insert table_1 (pprt_pkot_seq, pprt_mandant_nr, pprt_pro_prod_nr, pprt_prp_position ) values (l_seq, l_sucherg (i).pro_mandant_nr, l_sucherg (i).pro_prod_nr, l_sucherg (i).prp_position ); exception when others raise_application_error ( -20001, sqlerrm ); end; elsif l_prp_are_realartnr <> l_sucherg (i).prp_are_realartnr begin insert table_2 (patt_pkot_seq, patt_mandant_nr, patt_pro_prod_nr, patt_prp_position, patt_are_realartnr) values (l_seq, l_sucherg (i).pro_mandant_nr, l_sucherg (i).pro_prod_nr, l_sucherg (i).prp_position, l_sucherg (i).prp_are_realartnr ); l_prp_are_realartnr := l_sucherg (i).prp_are_realartnr; exception when others raise_application_error ( -20001, sqlerrm ); end; end if; l_pro_mandant_nr := l_sucherg (i).pro_mandant_nr; l_pro_prod_nr := l_sucherg (i).pro_prod_nr; l_prp_position := l_sucherg (i).prp_position; := l_sucherg.next (i); end loop;
Comments
Post a Comment