CREATE OR REPLACE PROCEDURE smooth(v_total integer, v_name text) AS
$$
DECLARE
    current integer;
BEGIN
    SELECT SUM(balance) FROM account INTO current;
    -- /!\ ICI LA RACE CONDITION
    UPDATE account SET balance = balance + (v_total - current)
    WHERE name = v_name;
END$$ LANGUAGE plpgsql;
