Considere os comandos abaixo no Oracle 12c, sequencialmente, de cima para baixo:
CREATE TABLE pacientes
(id integer,
nome varchar2(100),
sexo char(1));
create or replace function valida_paciente(p_nome varchar2, p_sexo char) return
boolean as
v_resultado integer;
begin
select count(*) into v_resultado from pacientes where nome = p_nome and sexo = p_sexo;
if v_resultado = 1 then
return false;
else
return true;
end if;
end;
create or replace trigger trg_pacientes
before insert on pacientes for each row
begin
if not valida_paciente(nome, sexo) then
raise_application_error(-20000,'PACIENTE DUPLICADO');
end if;
end;
insert into pacientes (id, nome, sexo) values (1, 'JOAO DA SILVA', 'M');
insert into pacientes (id, nome, sexo) values (2, 'MARIA OLIVEIRA', 'F');
insert into pacientes (id, nome, sexo) values (3, 'JOSE SILVEIRA', 'M');
insert into pacientes (id, nome, sexo) values (4, 'JOAO DA SILVA', 'M'); commit;
O que ocorrerá ao se executarem os referidos comandos?