CREATE TABLE maintable_pricetable (
id INTEGER NOT NULL
PRIMARY KEY AUTOINCREMENT,
transparency DECIMAL NOT NULL,
color DECIMAL NOT NULL,
pis DECIMAL NOT NULL,
purity DECIMAL NOT NULL,
intensity DECIMAL NOT NULL,
typicality DECIMAL NOT NULL,
purity2 DECIMAL NOT NULL,
intensity2 DECIMAL NOT NULL,
persistence DECIMAL NOT NULL,
typicality2 DECIMAL NOT NULL,
description VARCHAR (200) NOT NULL,
taster VARCHAR (20) NOT NULL,
date VARCHAR (10) NOT NULL,
harmony DECIMAL NOT NULL,
outcome VARCHAR (20),
сipher VARCHAR (6) NOT NULL
);
CREATE TRIGGER maintable_pricetable_sum_trigger_insert
BEFORE INSERT
ON maintable_pricetable
FOR EACH ROW
BEGIN
SET NEW.outcome = (NEW.transparency + NEW.color + NEW.pis + NEW.purity + NEW.intensity + NEW.typicality + NEW.purity2 + NEW.intensity2 + NEW.persistence + NEW.typicality2 + NEW.harmony);
END;
CREATE TRIGGER maintable_pricetable_sum_trigger_update
BEFORE UPDATE
ON maintable_pricetable
FOR EACH ROW
BEGIN
SET NEW.outcome = (NEW.transparency + NEW.color + NEW.pis + NEW.purity + NEW.intensity + NEW.typicality + NEW.purity2 + NEW.intensity2 + NEW.persistence + NEW.typicality2 + NEW.harmony);
END;
CREATE TRIGGER maintable_pricetable_sum_tr
AFTER INSERT
ON maintable_pricetable
FOR EACH ROW
BEGIN
UPDATE maintable_pricetable
SET outcome = (NEW.transparency + NEW.color + NEW.pis + NEW.purity + NEW.intensity + NEW.typicality + NEW.purity2 + NEW.intensity2 + NEW.persistence + NEW.typicality2 + NEW.harmony)
WHERE id = NEW.id;
END;