Stocks closed slightly higher Wednesday as investors picked up bargains, lifting indexes despite a new wave of earnings warnings from the technology sector and continued worries about the economy and oil prices.

The Dow Jones industrial average (search) gained 20.95 points, or 0.21 percent, to 10,240.29. The Standard & Poor's 500 Index (search) rose 2.12 points, or 0.19 percent, to 1,118.33. The technology-laced Nasdaq Composite Index (search) advanced 2.65 points, or 0.13 percent, to 1,966.08.

Software maker PeopleSoft (PSFT) on Wednesday said a hostile takeover bid by Oracle Corp. (ORCL) against the company has hurt its business and PeopleSoft slashed its second-quarter earnings forecast.

A day after major losses in small-cap and technology shares, investors took a chance on oversold stocks even as more tech companies warned that their profits will come in lower than expected.

Questions about the health of corporate earnings in the quarters ahead, however, kept their enthusiasm in check, and solid results from aluminum maker Alcoa Inc.and Internet media company Yahoo Inc. after the close appeared to do little to reduce their anxiety.

"This is a little bit of a relief rally, certainly some bargain hunting," said Peter Cardillo, chief strategist and senior vice president at S.W. Bach & Co. "This is a very nervous market, and it needs to hear better news from corporate America, telling it that the earnings growth is still in place. We're not hearing that from the technology sector."

All three major indexes had been down for the three previous sessions as investors worried that the economy was slowing. But despite the current negativity and warnings, some analysts believed a strong second quarter earnings season was still a given, in part due to the lower comparisons from a year ago, when companies were just starting to see their bottom lines recover from recession.

"I think the second quarter will see some blow-out type numbers," said Kevin Caron, market strategist at Ryan, Beck & Co. "I think that'll moderate somewhat in the second half of the year and into 2005, but the economy and earnings as a whole remains healthy."

During the regular session, a surge in gold prices above $400 an ounce boosted shares of mining companies, like Newmont Mining .

Data storage company EMC Corp. and telecommunications equipment maker Motorola Inc also rose, bouncing back from severe losses in recent sessions amid worries about slowing earnings growth.

"(Technology stocks) have gotten hit so hard ... It seems like earnings are slowing, and I think investors are very concerned, as they always are with that sector, given how volatile it can be," said Owen Fitzpatrick, head of the U.S. equity group at Deutsche Bank Private Banking.

Shares of Alcoa (AA) ended up 79 cents, or 2.5 percent, at $32.77 before the release of its earnings. It was the first Dow component to report second-quarter results. Alcoa, the world's biggest aluminum producer, said late Wednesday net income for the quarter rose sharply on strong sales of alumina and chemicals.

Yahoo (YHOO) fell 62 cents, or 1.9 percent, to $32.60 during the regular session. Its shares then tumbled about 13 percent in extended-hours trading to $28.43 even after it posted quarterly profit that more than doubled.

PeopleSoft (PSFT) erased earlier losses and rose 31 cents, or 1.8 percent, to $17.13, as investors bet PeopleSoft's weak performance could help Oracle make a stronger case to PeopleSoft's board for its $7.7 billion acquisition bid.

EMC (EMC) gained 80 cents, or 7.9 percent, to $10.96. On Tuesday, EMC and other data storage companies plunged sharply after Veritas Software Corp. (VRTS) , which sells data storage software, warned its results would disappoint.

Motorola (MOT) rose 52 cents, or 3.1 percent, to $17.37.

A surge in the price of gold, which jumped as the dollar sank to a 3-month low against the euro, sent shares of precious metals mining companies higher. Freeport-McMoRan Copper & Gold led the way with a gain of $2.21, or 6.8 percent, to $34.74. Newmont Mining rose $1.73, or 4.4 percent, to $41.12.

The Gold Bugs index of gold company stocks rose 3.4 percent and the Gold/Silver index jumped 4 percent. In New York, the COMEX gold for August delivery shot up $9.70 to settle at $402.70 an ounce. Earlier, the contract hit a session peak at $404, its highest since June 28.

Even software giant Microsoft (MSFT) isn't immune to the crunch. Microsoft lost 38 cents to $27.64 after chief executive Steve Ballmer, in a memo to employees, said the company would trim $1 billion in expenses by reducing prescription drug benefits and stock discounts for its workers.

In other news, consulting firm Accenture Ltd. (ACN) matched Wall Street estimates with a 59 percent surge in quarterly profits. Accenture gained a penny to $27.25.

Nasdaq market maker Knight Trading Group Inc. (NITE) was down 49 cents at $8.74 after it said it would take a $79 million charge in the second quarter to settle a federal investigation into its trading practices. The company's second-quarter earnings will also come in below estimates due to stock volatility and low trading volume.

Trading was moderate, with about 1.3 billion shares traded on the New York Stock Exchange and 1.8 billion shares traded on Nasdaq.

The Russell 2000 index of smaller companies was down 0.46, or 0.1 percent, at 571.95.

Overseas, Japan's Nikkei stock average fell 0.8 percent. In Europe, Britain's FTSE 100 closed down 0.3 percent, France's CAC-40 was flat for the session and Germany's DAX index lost 0.4 percent.

Reuters and the Associated Press contributed to this report.