A stored procedure is a set of SQL statements (and procedural logic) saved in the database and executed by name. It runs logic inside the database rather than in application code. They have real benefits but also significant trade-offs, so when to use them is a genuine design decision.
A stored procedure
transfer_funds(from_id , to_id , amount )
plpgsql $$
accounts balance balance amount id from_id;
accounts balance balance amount id to_id;
;
$$;
transfer_funds(, , );
