* TSX up 8.63 points, or 0.07 percent, at 13,256.69
* Two biggest railways jump on strong earnings
* Glut of oil in U.S. weighs on energy companies
By Alastair Sharp
TORONTO, Oct 23 (Reuters) - Canada's main stock index eked out a small gain in morning trade on Wednesday as strong results from the country's two biggest railways offset losses in energy and mining companies.
Canadian Pacific Railway Ltd, Canada's No. 2 rail operator, surged 6.2 percent to C$143.20 after reporting a 45 percent jump in profit as freight revenue rose and operating costs fell.
Canadian National Railway Co, the No. 1 operator and focus of scrutiny after one of its trains derailed and caught fire last weekend, jumped 2.7 percent to C$112.71 after reporting a market-beating third-quarter profit and record revenue late on Tuesday, as well as a two-for-one stock split and share buyback plan.
The railways should prosper as the economy grows but the potential for growing opposition to their carriage of natural resources was a concern, said Rick Hutcheon, president and chief operating officer at RKH Investments.
"A great deal of the current growth in their earnings is coming from oil-by-rail," he said.
The Toronto Stock Exchange's S&P/TSX composite index was up 8.63 points, or 0.07 percent, at 13,256.69 by mid-morning. It opened in the red. The index has been on a six-session rally, pushing it to two-year highs.
Energy stocks weighed most heavily, pressured by ample supplies and expectations of a further inventory buildup in the United States, the world's top consumer.
Suncor Energy Inc slipped 1.4 percent to C$36.98 and Canadian Natural Resources Ltd declined 1.5 percent to C$32.50.
CGI Group fell 3.5 percent to C$34.80. The contractor that built HealthCare.gov has fallen 9 percent in the last week as the U.S. health insurance program suffered technical glitches.