Bug #2174 ยป trigger updatevalidtroughtimfi.txt
1 |
USE MinovaHR_Indomobil_Dev; |
---|---|
2 |
GO |
3 |
|
4 |
CREATE TRIGGER [dbo].UpdateValidtrought |
5 |
ON [dbo].[hr_md_emp_md0002] |
6 |
AFTER UPDATE |
7 |
AS |
8 |
BEGIN |
9 |
-- Cek jika kolom movement_type diperbarui ke '80' |
10 |
IF UPDATE(movement_type) |
11 |
BEGIN |
12 |
-- Perbarui kolom valid_through di base_sys_user berdasarkan start_date di [hr_md_emp_md0002] |
13 |
UPDATE B |
14 |
SET B.valid_through = A.[start_date] |
15 |
FROM base_sys_user AS B |
16 |
INNER JOIN [hr_md_emp_md0002] AS A ON B.emp_id = A.emp_id |
17 |
INNER JOIN inserted AS I ON A.emp_id = I.emp_id |
18 |
INNER JOIN deleted AS D ON A.emp_id = D.emp_id |
19 |
WHERE I.movement_type = '80' AND (D.movement_type <> '80' OR D.movement_type IS NULL); |
20 |
END; |
21 |
END; |