Why not fold the value of the column?

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);


Trigger:
CREATE OR REPLACE FUNCTION autocountfunc() RETURNS TRIGGER AS $big_bank$
BEGIN
 NEW.total = NEW.score + (NOV.percent/100 * NEW.score);
 RETURN NEW;
END;
$big_bank$ LANGUAGE plpgsql;

Auto_count CREATE TRIGGER BEFORE INSERT OR UPDATE ON big_bank FOR EACH ROW EXECUTE PROCEDURE autocuontfunc();


I bring data to the table:
INSERT INTO big_bank (fio, percent, score) VALUES ('Vittorio Scaletta A' , 2.0, 60000);


It should be the value total = 61200$, but calculates total = 1200$, why? I can not understand...

psql v.9.3.13
April 3rd 20 at 18:36
1 answer
April 3rd 20 at 18:38
Solution
CREATE OR REPLACE FUNCTION autocountfunc()
EXECUTE PROCEDURE autocuontfunc()

Do not use the function which see.
EXECUTE PROCEDURE autocuontfunc() RETURNS TRIGGER AS $big_bank$, right? - heath_Hilpert commented on April 3rd 20 at 18:41
well, that's to you as a developer the question is how to call - Lora commented on April 3rd 20 at 18:44
@Lora, no, just, I whether the command written? - heath_Hilpert commented on April 3rd 20 at 18:47
look in the documentation.
In the issue the syntax is correct. I quoted two excerpts from the question to show an immediate error. Look at the names of the functions. - Lora commented on April 3rd 20 at 18:50
@Lora, I am on this W... x a week protofibril... - heath_Hilpert commented on April 3rd 20 at 18:53

Find more questions by tags PostgreSQL