Buscar..
Introducción
Introducción:
Los disparadores son un concepto útil en PL / SQL. Un disparador es un tipo especial de procedimiento almacenado que no requiere ser llamado explícitamente por el usuario. Es un grupo de instrucciones, que se activan automáticamente en respuesta a una acción de modificación de datos específica en una tabla o relación específica, o cuando se cumplen ciertas condiciones específicas. Los activadores ayudan a mantener la integridad y la seguridad de los datos. Hacen el trabajo conveniente tomando la acción requerida automáticamente.
Sintaxis
- CREAR [O REEMPLAZAR] TRIGGER trigger_name
- ANTES DE ACTUALIZAR [o INSERTAR] [o BORRAR]
- ON table_name
- [ POR CADA FILA ]
- DECLARAR
- - Declaraciones variables
- EMPEZAR
- - código de activación
- EXCEPCIÓN
- CUANDO ...
- -- manejo de excepciones
- FIN;
Antes de activar INSERT o ACTUALIZAR
CREATE OR REPLACE TRIGGER CORE_MANUAL_BIUR
BEFORE INSERT OR UPDATE ON CORE_MANUAL
FOR EACH ROW
BEGIN
if inserting then
-- only set the current date if it is not specified
if :new.created is null then
:new.created := sysdate;
end if;
end if;
-- always set the modified date to now
if inserting or updating then
:new.modified := sysdate;
end if;
end;
/
Modified text is an extract of the original Stack Overflow Documentation
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow