Preparation of carboxylic acid esters by oxidation of groups which are precursors for the acid moiety of the ester by oxidation of primary alcohols