Weak decays of heavy mesons in the static quark approximation