sql - Oracle Insert Into If NOT Exist -
i'm wirting , pl_sql script inserts if condition not exist
and not working me :(
this code
params in cursor
for ps in params loop compteur := 5; loop if not exists (select * carp.table1 fk_tab1 =ps.id_tab1 , dic_type = compteur ) begin insert carp.table1 ( id, fk_tab1, dic_type ) values ( id.nextval , ps.id_tab1 , compteur ) end compteur:=compteur-1; commit; exit when compteur <0; end loop; end loop;
thanks in advance
usually use such checking , if not exists
doesnt work on oracle (as far know)
declare cnt number(4); begin select count(1) cnt carp.table1 fk_tab1 =ps.id_tab1 , dic_type = compteur if cnt = 0 insert carp.table1 ( id, fk_tab1, dic_type ) values ( id.nextval , ps.id_tab1 , compteur ) end if; end; / commit /
Comments
Post a Comment