CHICAGO, Oct 20 (Reuters) - U.S. corn futures hit a two-week high on Wednesday and soybean futures also advanced, supported by brisk global demand, firm cash markets and surging vegetable oil prices.

U.S. wheat futures rose as Minneapolis Grain Exchange spring wheat futures set a nine-year top on tightening global supplies of high-quality milling wheat.

Additional support stemmed from a weaker dollar, which tends to make U.S. grains more attractive on the world market. The dollar dipped as risk sentiment improved.

Chicago Board of Trade December corn settled up 9 cents at $5.39-1/4 per bushel after reaching $5.40, its highest since Oct. 6. November soybeans ended up 17-1/2 cents at $12.45-1/2 per bushel.

CBOT December wheat finished up 13-1/4 cents at $7.49-1/4 per bushel and MGEX wheat reached $9.94-1/2, the highest on a continuous chart of the spot contract since July 2012.

With the U.S. harvest of corn and soybeans more than halfway complete, some end-users are raising their basis bids as they work to draw out supplies from farmers. Grain offerings have been limited by rains slowing fieldwork in the eastern Midwest, and worries among growers about rising costs for crop inputs such as fertilizer.

"With inputs going up, the producer is uncertain what his costs are going to be. So he is selling the excess (grain) that he can't store, but holding on to the rest because of inflationary fears," said Don Roose, president of Iowa-based U.S. Commodities.

Meanwhile, the U.S. Energy Information Administration said weekly production of corn-based ethanol in the latest week rose to 1.096 million barrels per day, the biggest weekly total since June 2019, while stockpiles rose to 20.080 million barrels.

Tightening global supplies of vegetable oil lent support to the soy complex. Malaysian palm oil futures rose more than 2% to a record closing high, ICE canola futures surged to life-of-contract highs and November rapeseed futures on Paris-based Euronext rose to 700 euros a tonne, matching a record price set earlier this year.

CBOT December soyoil futures recorded a higher close for a sixth straight session, settling up 2.31 cents at 64.70 cents per pound after reaching 64.90 cents, the contract's highest level since July 30.

In China, constant rains in recent weeks have slowed wheat planting and autumn harvesting, a government official said on Wednesday.

(Reporting by Julie Ingwersen; additional reporting by Gus Trompiz in Paris and Naveen Thukral in Singapore; Editing by Subhranshu Sahu, David Evans, Alison Williams and Mark Porter)