The benchmark S&P 500 stock market index plunged into bear territory during 2022. But it has soared 29% from its low point set in October of that year, prompting some Wall Street analysts to call the beginning of a new bull market.

Not everyone agrees with that classification. Other experts think the S&P 500 has to reclaim its all-time high before the bear officially returns to hibernation. But here's the good news: After Wednesday's close, the index has to climb less than 2% to get there, so a new bull market could be right around the corner (by every definition). Therefore, now might be a great time for investors to buy quality stocks.

One to consider now is Oracle (ORCL 2.02%). The massive database software company just reported financial results for its fiscal 2024 second quarter (ended Nov. 30), and investors immediately sent its stock plunging by 9%. But that isn't the whole story. Here's why Oracle stock might represent one of the best long-term buying opportunities available right now.

In the midst of an incredible transition

Oracle is one of America's oldest technology companies. Founded in 1977 -- within a couple of years of both Apple and Microsoft -- its relational database management software was a smash hit in the 1980s. And in the 1990s, the company helped its customers prepare for the age of the internet.

That evolved into cloud services in the 2010s, and Oracle Cloud Infrastructure was officially launched in 2016 to deliver powerful computing power to customers through centralized data centers. Today, almost every organization in the world relies on the cloud in some capacity to run their operations online.

But we just entered the age of artificial intelligence (AI), and it could be Oracle's largest opportunity ever. AI is currently developed, trained, and deployed in the cloud, and it requires substantial amounts of computing power, which can only be delivered by specialized chips from providers like Nvidia. They can sell for over $40,000 each, so it's far too expensive for most businesses to build their own infrastructure.

Therefore, it's left to experienced data center operators like Oracle who can build and manage the infrastructure at scale. In fact, Oracle's latest second-generation data centers -- called Gen2 Cloud -- are constructed with automation at their core. Oracle Chairman Larry Ellison says this infrastructure is very cost efficient; in fact, he said there is no difference in costs between managing 10 data centers and 100 data centers thanks to autonomous technologies.

The result is a cheap and efficient experience for the end user. Earlier this year, Ellison said Oracle's Gen2 Cloud has become the No. 1 choice for running generative AI workloads because its proprietary GPU cluster technology has the highest performance, and the lowest cost, in the world.

The challenge of meeting demand

Demand is so great that Oracle now has a supply problem. Ellison said the company is in the process of expanding 66 of its existing data centers while building 100 more, because it has billions of dollars in contracted demand that it currently can't supply. Nvidia's advanced AI data center chips are one of the constraints. Oracle simply can't get its hands on enough of them.

Ellison said demand for the company's cloud infrastructure and generative AI services is increasing at an "astronomical rate." It showed up in the numbers; even while Oracle's total revenue grew by a modest 5% year over year (which disappointed investors), Oracle Cloud Infrastructure revenue soared 52% in the second quarter of Oracle's fiscal 2024.

It only accounted for $1.6 billion of the company's $12.9 billion in total sales, but Ellison said he expects the segment to grow above 50% for years to come, and at that pace it won't be long before it's the driving force behind Oracle overall.

An infographic breaking down Oracle's latest financial results for the fiscal 2024 second quarter.

Data source: Oracle. Infographic by The Motley Fool.

Oracle did, however, deliver a whopping 44% gain in net income (profit). As I touched on earlier, Gen2 infrastructure is incredibly cost efficient, so strong increases in the company's bottom line should continue especially once it completes construction of its latest data centers and brings them online. As Oracle Cloud Infrastructure becomes a larger part of Oracle's business, it will likely boost the company's profitability overall.

Why Oracle stock is a screaming buy

Oracle has attracted some of the leading developers of AI, including Adept AI, Cohere, and even Elon Musk's xAI, which just launched its large language model called Grok. These start-ups have already committed to spending billions of dollars on Gen2 Cloud capacity, and in the case of xAI, Musk already wants significantly more GPUs than Oracle can possibly provide right now. Ellison wasn't kidding when he said demand was astronomical.

With that in mind, Oracle stock looks extremely attractive right now. The company has generated $3.62 in trailing-12-month earnings per share, and based on its current stock price of $105, it trades at a price-to-earnings (P/E) ratio of 29.

By comparison, Microsoft, another cloud-focused AI stock, trades at a much higher P/E ratio of 35.9. Oracle stock would have to gain 24% from here just to catch up, which makes it seem like a bargain at the current price especially considering the company's rapid earnings growth.

Longer-term, AI is going to be one of the greatest financial opportunities in the tech sector's history. A report by research and consulting firm McKinsey & Company suggests 70% of companies will use AI by 2030, adding $13 trillion to global economic output. Considering Oracle's Gen2 Cloud is the top choice for generative AI workloads, its stock will likely be a great place for your money, especially at this price.