Ver Mensaje Individual
  #4 (permalink)  
Antiguo 01/02/2012, 22:43
Avatar de matanga
matanga
 
Fecha de Ingreso: octubre-2007
Ubicación: España
Mensajes: 1.091
Antigüedad: 16 años, 6 meses
Puntos: 85
Respuesta: verificar si un valor existe a través de un IF

Tienes varias opciones para validar si existe un registro, no hay mucha diferencia en rendimiento, es más una cuestión de gusto.

1. Como comenta huesos52, utilizar excepciones.

2. Hacer un count

Código:
select count(dato_1) into aux2 
 from tabla
 where dato_1 = "nombre_1";
 if aux2 > 0 then
 --el registro existe
 end if;
3. Hacer un cursor for loop

Código:
for cur in (select dato_1 from tabla
                where dato_1 = "nombre_1") loop
 --el registro existe
end loop;
Saludos