Home » SQL & PL/SQL » SQL & PL/SQL » Trigger
Trigger [message #1230] |
Fri, 12 April 2002 09:22 |
Fred
Messages: 34 Registered: August 1999
|
Member |
|
|
Hi all!
I´m trying to create a Trigger (BEFORE INSERT OR UPDATE) that if INSERTING it would let it insert, but if UPDATING it does sth else. The thing is that if UPDATING it DOES NOT HAVE to continue with the insert, it has to make it stop.
Any ideas? Thanx in adv.
Fred.-
|
|
|
|
Re: Trigger [message #2329 is a reply to message #1230] |
Sun, 07 July 2002 14:16 |
Raul Flores
Messages: 1 Registered: July 2002
|
Junior Member |
|
|
I have a problem creating a Trigger.
When having an input for an absence by an employee I must to review if this day is marked as busy in the Kardex by another absence avoiding a double input of the same absence, I have if it is busy or not, but I don't know how to stop the inserting, because if it is busy it is an invalid input.
I have the trigger so far:
create or replace trigger TGR_KARDEX
before insert or delete on capturas
declare
-- local variables here
vKarSts_str as varchar(1);
begin
FOR EACH ROW
WHEN (TI.FNTCONCVEAUS_STR(new.CONCEPTO) <> ' ')
BEGIN
IF INSERTING THEN
IF TI.FNTCONCVEAUS_STR(:NEW.Concepto) <> ' ' THEN
IF TI.FNTKARDEXSTS_STR(:NEW.Num_emp,:NEW.Fecha_Pago) <> ' ' THEN
IF TI.FNTKARDEXSTS_STR(:NEW.Num_emp,:NEW.Fecha_Pago) <> '-' THEN
--Kardex Busy Exit and not let to insert this record
ELSE
--Kardex does not exists. Inser the Kardex for this year and update it
INSERT INTO HUMAN.HU_EMPLS_ASISTENCIA
( AS_CIA,
AS_NUM_EMP,
AS_AA_PROC,
AS_MES01,
AS_MES02,
AS_MES03,
AS_MES04,
AS_MES05,
AS_MES06,
AS_MES07,
AS_MES08,
AS_MES09,
AS_MES10,
AS_MES11,
AS_MES12 )
VALUES ( TI.FNTEMPCIA_INT(:NEW.Num_emp),
:NEW.Num_emp,
to_char(:NEW.Fecha_Pago,'y'),
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ' ) ;
vKarSts_str := TI.fntKardexdel_str(:NEW.Num_Emp,:NEW.Fecha_Pago,:NEW.Concepto)
END IF
ELSE --Update the record with the absence key
vKarSts_str := TI.fntKardexins_str(:NEW.Num_Emp,:NEW.Fecha_Pago,:NEW.Concepto)
END IF
END IF
ELSE --This is deleting so clear the absence key
vKarSts_str := TI.fntKardexdel_str(:NEW.Num_Emp,:NEW.Fecha_Pago,:NEW.Concepto)
END IF;
END;
end TGR_KARDEX;
Thanks in advance,
|
|
|
Goto Forum:
Current Time: Fri Apr 19 12:42:40 CDT 2024
|