Answer the question
In order to leave comments, you need to log in
Why doesn't it add up the column value?
Table:
CREATE TABLE big_bank(
id SERIAL NOT NULL PRIMARY KEY,
fio TEXT NOT NULL,
percent NUMERIC DEFAULT 0,
score MONEY DEFAULT 0,
total MONEY DEFAULT 0);
CREATE OR REPLACE FUNCTION autocountfunc() RETURNS TRIGGER AS $big_bank$
BEGIN
NEW.total = NEW.score + (NEW.percent/100 * NEW.score);
RETURN NEW;
END;
$big_bank$ LANGUAGE plpgsql;
CREATE TRIGGER auto_count BEFORE INSERT OR UPDATE ON big_bank FOR EACH ROW EXECUTE PROCEDURE autocuontfunc();
INSERT INTO big_bank (fio, percent, score) VALUES ('Vittorio Scaletta A' , 2.0, 60000);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question