Oracle Corp., the world’s largest seller of database software, agreed to buy Responsys Inc. for about $1.5 billion, gaining marketing software that helps businesses sell to consumers.

Oracle will pay $27 a share in cash for the company, according to a statement today. That represents a 38 percent premium over Responsys’ closing price yesterday. The transaction is expected to close in the first half of next year.

Responsys, based in San Bruno, California, sells marketing software via the cloud, meaning it’s delivered online. The deal will add to Oracle’s growing cloud revenue, which helped quarterly sales and profit top estimates earlier this week.

“This one has a potential to be a very nice acquisition for Oracle because there is not a lot of overlap with what Responsys does on the marketing side,” said Matthew Hedberg, an analyst at RBC Capital Markets in Minneapolis. “It makes a lot of sense, and it certainly accelerates their strategic transition to more cloud-based revenue.”

Responsys’ stock surged 39 percent to $27.08 at 10:45 a.m. in New York, capping a more than threefold gain this year. Shares of Redwood City, California-based Oracle rose 0.2 percent to $36.66.

Oracle is using acquisitions to embrace cloud computing and shift away from traditional software, which is stored on local computers. Chief Executive Officer Larry Ellison has spent about $50 billion to buy about 100 companies over the past decade, seeking to keep 36-year-old Oracle relevant to customers. Those deals include Oracle’s acquisition earlier this year of Morrisville telecommunications equipment vendor Tekelec.

Beating Estimates

While its sales and profit growth have slowed in recent years, Oracle’s latest earnings gave investors confidence that the company was weathering the transition. Revenue for the quarter ended in November climbed 2 percent to $9.28 billion, while profit excluding some items was 69 cents a share. Analysts had estimated $9.18 billion in sales and earnings of 67 cents, according to data compiled by Bloomberg.

Responsys develops software that helps marketing executives handle commerce, sales and social networking. It will become part of Oracle’s Customer Experience Cloud, a package of business services. That means chief marketing officers will get the tools they need in one place, said Mark Hurd, Oracle’s president.

“Our strategy of combining the leaders across complementary technologies signifies Oracle’s overwhelming commitment to winning and serving the CMO better than any other software company in the world,” he said in today’s statement.