Stocks were flat on Wednesday, with even a blowout quarter at Apple failing to entice investors to carry on buying the day after Wall Street's best day since March.

The bellwether's results follow similarly strong numbers from IBM and Coca-Cola that helped underscore the growing sense companies were faring well despite the economic soft patch. However, sovereign debt problems in the United States and Europe continue to worry the market.

There's still tremendous uncertainty around the U.S. debt ceiling and the euro-zone, and while earnings have been good it isn't surprising to have a big up day followed by a down day, said David Carter, chief investment officer at Lenox Advisors in New York.

Sales of previously owned U.S. homes unexpectedly fell to a seven-month low in June as cancellations of pending contracts surged, according to the National Association of Realtors.

Tech giant Apple late on Tuesday reported third-quarter revenue that was far above expectations, helped by its Asian business and blockbuster sales of its iPhone. The stock gained 3.3 percent to $389.01.

Among the early reporting companies on Wednesday was Dow component United Technologies Inc , which raised its full-year profit view. Textron Inc reported a second-quarter profit that beat expectations.

Shares of Textron rose 6.9 percent to $23.64 while United Tech sank 2.4 percent to $86.72.

Earnings continue to exceed expectations, and the positive momentum is still there, said Phil Flynn, senior market analyst with PFG Best in Chicago, who added that the S&P was poised to top its 2011 high, reached in April.

The Dow Jones industrial average <.DJI> was down 4.16 points, or 0.03 percent, at 12,583.26. The Standard & Poor's 500 Index <.SPX> was up 1.22 points, or 0.09 percent, at 1,327.95. The Nasdaq Composite Index <.IXIC> was down 5.59 points, or 0.20 percent, at 2,820.93.

Weighing on the Nasdaq was Yahoo Inc , which fell 6 percent to $13.71 a day after reporting a decline in second-quarter revenue.

Apart from earnings, AMR Corp , the parent company of American Airlines, rose 2.2 percent to $5.03 after the company said it plans to buy 460 narrowbody Boeing Co 737s and Airbus EADS A320s beginning in 2013. Dow component Boeing surged 3.3 percent to $72.88.

Also, Ecolab Co said it would buy Nalco Holding Co for $5.4 billion, sending shares of Nalco up 25 percent to $36.09. Ecolab shares were down 7.4 percent to $51.30.

The growing optimism over earnings season comes as market participants also gain more confidence in the talks for a debt deal in the United States. Markets gained momentum late in the day on Tuesday after President Barack Obama suggested progress was being made toward a $3.75 trillion deficit reduction deal centered around entitlement reform.

The White House and Congress need an agreement that includes an increase in the federal debt ceiling by August 2 or the United States could default on its debt.

(Editing by Chizu Nomiyama)