* Shell, Total avoided expected loss due to trading

* Eni's marketing unit shines in challenging quarter

* Energy firms flagged big writedowns in second quarter

* Exxon, Chevron results due July 31, BP on Aug. 4

LONDON, July 30 (Reuters) - The trading units of European oil and gas majors have shielded their second-quarter results from the full force of the corona-induced collapse in demand for fuel, but big writedowns showed the scale of the challenge ahead, results showed on Thursday.

France's Total and Anglo-Dutch Royal Dutch Shell scraped out small profits against expectations of losses with the help of the trading units which can exploit market gyrations even when prices fall.

"These results are driven in particular by the outperformance of trading activities, once again demonstrating the relevance of Total's integrated model," Total Chief Executive Patrick Pouyanne said in a statement.

Shell Chief Financial Officer Jessica Uhl said the company had "stellar" trading results due to "solid, good market conditions," in particular high volatility in oil prices which allows nimble traders to take advantage of small changes in order to buy, store or sell fuels.

Earnings of $1.5 billion at Shell's trading unit in the quarter was about 30 times higher than a year ago. This mirrored Equinor's results last week, where trading helped the Norwegian company avoid an operating loss.

Oil prices plunged below $16 a barrel in April from above $60 at the start of the year, as daily global crude consumption plunged by as much as a third. Prices have regained some ground since then to trade above $40.

Eni's refining and marketing unit's second-quarter profit shot up by 76% to $139 million compared with a year ago, although the company overall still swung to a loss, it said on Thursday.

But trading earnings have not protected the companies from the gloomier longer term prospects for demand. The pandemic has prompted energy firms to slash long-term crude price outlooks, cutting the value of their assets.

France's Total wrote down $8 billion in the quarter, while Shell cut the value of its assets by $16.8 billion. Eni wrote down 3.5 billion euros ($4.1 billion) and BP, due to report second-quarter results on Aug. 4, has guided for a $17.5 billion hit.

Shell responded to the pandemic by cutting its dividend for the first time since World War Two and lowering planned spending this year by $5 billion to a maximum of $20 billion.

Eni cut its dividend and introduced a new dividend policy based on the oil price. Equinor also cut its dividend and suspended a share buyback.

BP and Total have not cut their dividends.

U.S. oil and gas majors Chevron and Exxon are due to report on July 31.

($1 = 0.8503 euros)

(Reporting by Shadia Nasralla and Ron Bousso in London and Bate Felix in Paris; Editing by Edmund Blair and Alexandra Hudson)