all you need do is add an exception clause to catch the ora-00001.
orcl> create procedure newd as begin 2 insert into dept(deptno) values (99); 3 end; 4 / Procedure created. orcl> exec newd; PL/SQL procedure successfully completed. orcl> exec newd; BEGIN newd; END; * ERROR at line 1: ORA-00001: unique constraint (SCOTT.PK_DEPT) violated ORA-06512: at "SCOTT.NEWD", line 2 ORA-06512: at line 1 orcl>
begin Select id into is_id from mytable where id=p_id ; < do updates or whatever you need to do with exiisting row> exception when no_data_found then insert into mytable values (..); end;