'Why the Trigger is not working in Postgresql

I want to update the "noofdays" column with the below trigger. But it is not working and I've attached the trigger code and the table structure below

CREATE OR REPLACE FUNCTION update_days() RETURNS TRIGGER AS $$
  BEGIN
        new."noofdays":=1;
    RETURN new;
  END; 
$$ LANGUAGE plpgsql;
CREATE TRIGGER calc_days before UPDATE ON bookentry FOR EACH STATEMENT EXECUTE PROCEDURE update_days();
 bookid     | integer                     |           |          |
 loginid    | integer                     |           |          |
 borrowtime | timestamp without time zone |           | not null | now()
 returntime | timestamp without time zone |           |          |
 noofdays   | integer                     |           |          |


Solution 1:[1]

You need a row level trigger:

CREATE TRIGGER calc_days 
   before UPDATE ON bookentry 
   FOR EACH ROW  --<< this
   EXECUTE PROCEDURE update_days();

Solution 2:[2]

You should trig a row level trigger:

CREATE TRIGGER calc_days 
before UPDATE ON bookentry 
FOR EACH ROW  --<< this
EXECUTE PROCEDURE update_days();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 a_horse_with_no_name
Solution 2 Pylyp Dukhov