- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
CREATE TRIGGER after_update_limit AFTER UPDATE ON limits
FOR EACH ROW
BEGIN
SET @annual_normative = NULL;
SET @ud_use = NULL;
SET @ud_disposal = NULL;
SET @placed_deposited = NULL;
SET @placed_disposal = NULL;
SET @custom1_disposal = NULL;
SET @custom1_deposited = NULL;
SET @custom1_use = NULL;
SET @custom1_neutralization = NULL;
SET @custom2_disposal = NULL;
SET @custom2_deposited = NULL;
SET @custom2_use = NULL;
SET @custom2_neutralization = NULL;
SET @custom3_disposal = NULL;
SET @custom3_deposited = NULL;
SET @custom3_use = NULL;
SET @custom3_neutralization = NULL;
SET @custom4_disposal = NULL;
SET @custom4_deposited = NULL;
SET @custom4_use = NULL;
SET @custom4_neutralization = NULL;
SET @custom5_disposal = NULL;
SET @custom5_deposited = NULL;
SET @custom5_use = NULL;
SET @custom5_neutralization = NULL;
SELECT
SUM(annual_normative), SUM(ud_use), SUM(ud_disposal), SUM(placed_deposited), SUM(placed_disposal),
SUM(custom1_disposal), SUM(custom1_deposited), SUM(custom1_use), SUM(custom1_neutralization),
SUM(custom2_disposal), SUM(custom2_deposited), SUM(custom2_use), SUM(custom2_neutralization),
SUM(custom3_disposal), SUM(custom3_deposited), SUM(custom3_use), SUM(custom3_neutralization),
SUM(custom4_disposal), SUM(custom4_deposited), SUM(custom4_use), SUM(custom4_neutralization),
SUM(custom5_disposal), SUM(custom5_deposited), SUM(custom5_use), SUM(custom5_neutralization)
INTO
@annual_normative, @ud_use, @ud_disposal, @placed_deposited, @placed_disposal,
@custom1_disposal, @custom1_deposited, @custom1_use, @custom1_neutralization,
@custom2_disposal, @custom2_deposited, @custom2_use, @custom2_neutralization,
@custom3_disposal, @custom3_deposited, @custom3_use, @custom3_neutralization,
@custom4_disposal, @custom4_deposited, @custom4_use, @custom4_neutralization,
@custom5_disposal, @custom5_deposited, @custom5_use, @custom5_neutralization
FROM limits
WHERE id_enterprise = NEW.id_enterprise;
UPDATE limits_total
SET
annual_normative = @annual_normative, ud_use = @ud_use, ud_disposal = @ud_disposal, placed_deposited = @placed_deposited, placed_disposal = @placed_disposal,
custom1_disposal = @custom1_disposal, custom1_deposited = @custom1_deposited, custom1_use = @custom1_use, custom1_neutralization = @custom1_neutralization,
custom2_disposal = @custom2_disposal, custom2_deposited = @custom2_deposited, custom2_use = @custom2_use, custom2_neutralization = @custom2_neutralization,
custom3_disposal = @custom3_disposal, custom3_deposited = @custom3_deposited, custom3_use = @custom3_use, custom3_neutralization = @custom3_neutralization,
custom4_disposal = @custom4_disposal, custom4_deposited = @custom4_deposited, custom4_use = @custom4_use, custom4_neutralization = @custom4_neutralization,
custom5_disposal = @custom5_disposal, custom5_deposited = @custom5_deposited, custom5_use = @custom5_use, custom5_neutralization = @custom5_neutralization
WHERE id_enterprise = NEW.id_enterprise
LIMIT 1;
END;
Сперва можно посмеяться, а затем подскажите, пжл, как тоже самое написать по человечески ???