Palladium-catalyzed, one-pot carbonylation of heterocyclic compounds into their esters, in the presence of mercury salts.