MaxAPEX

RAG in Oracle APEX 24.2

RAG in Oracle APEX 24.2: A Step-by-Step Guide for Developers

Below is a detailed blog post tailored for Oracle APEX developers, explaining Retrieval-Augmented Generation (RAG) in APEX 24.2. It includes a step-by-step guide and a sample use case with complete code. This is designed to be practical, engaging, and immediately useful for APEX developers looking to leverage AI in their applications.


Mastering Retrieval-Augmented Generation (RAG) in Oracle APEX 24.2: A Complete Guide for Developers

Oracle APEX 24.2 brings a wave of AI-driven enhancements, and one of the standout features is Retrieval-Augmented Generation (RAG). If you’re an APEX developer eager to make your applications smarter by integrating real-time, context-aware AI responses grounded in your own data, this blog is for you. We’ll dive into what RAG is, how it works in APEX 24.2, and provide a step-by-step guide with a sample use case—complete with code—to get you started. By the end, you’ll have a working RAG-powered feature in your APEX app. Let’s get to it!

What is RAG, and Why Should APEX Developers Care?

Retrieval-Augmented Generation (RAG) is a technique that supercharges AI by combining two steps: 1. Retrieval: Fetching relevant data from an external source (like your database). 2. Generation: Using an AI model (e.g., via Oracle’s AI services) to craft a response based on that data.

Unlike traditional AI that relies solely on pre-trained knowledge (which can be outdated or generic), RAG ensures responses are fresh, specific, and tied to your application’s data. In APEX 24.2, this is made declarative and seamless through AI Configurations and RAG Sources, allowing you to enhance the APEX AI Assistant or power custom AI-driven features.

For APEX developers, this means: – Contextual Intelligence: Deliver answers based on your app’s live data. – Low-Code Power: Set it up without writing complex AI code. – Real-World Impact: Solve problems like customer queries, data summaries, or dynamic content generation.

RAG in APEX 24.2: How It Works

In APEX 24.2, RAG is baked into the platform via: – AI Configurations: A new Shared Component where you define system prompts, welcome messages, and RAG Sources. – RAG Sources: Dynamic data feeds (SQL queries, PL/SQL functions, or static text) that the AI uses to augment its responses. – Integration Points: Use RAG with the APEX AI Assistant or the “Generate Text with AI” Dynamic Action.

The process is straightforward: 1. A user asks a question (e.g., through a text field or AI Assistant). 2. APEX retrieves relevant data from RAG Sources based on the prompt. 3. The AI combines the retrieved data with the user’s input to generate a response.


Step-by-Step Guide: Building a RAG-Powered Feature

Let’s walk through setting up RAG in APEX 24.2, step by step. Our goal? Create a simple customer support app where users can ask about their orders, and the AI responds with accurate, data-driven answers.

Step 1: Set Up Your APEX Environment
  • Ensure you’re using Oracle APEX 24.2 with an Oracle Database (ideally 23ai for vector search, but 19c+ works for basic RAG).

  • Configure an AI Service (e.g., Oracle OCI Generative AI or a third-party provider like OpenAI) in your workspace under Shared Components > AI Services.

Step 2: Create a Sample Table

We’ll simulate a customer orders database. Run this SQL in SQL Workshop:

CREATE TABLE customer_orders (
    order_id NUMBER PRIMARY KEY,
    customer_id NUMBER,
    order_status VARCHAR2(20),
    order_date DATE,
    details VARCHAR2(4000)
);

INSERT INTO customer_orders VALUES (1, 101, ‘Shipped’, SYSDATE – 2, ‘Order of 5 laptops, shipped via FedEx.’);
INSERT INTO customer_orders VALUES (2, 102, ‘Pending’, SYSDATE – 1, ‘Order of 3 monitors, awaiting stock.’);
INSERT INTO customer_orders VALUES (3, 101, ‘Delivered’, SYSDATE – 5, ‘Order of 1 printer, delivered to office.’);

Step 3: Define an AI Configuration
  1. Go to Shared Components > AI Configurations.
  2. Click Create.
  3. Set:
    1. Name: OrderSupportAI
    1. System Prompt: You are a customer support assistant. Use the provided order data to answer user questions accurately.
    1. Welcome Message: Ask me anything about your orders!
  4. Save it for now—we’ll add RAG Sources next.

Step 4: Add a RAG Source
  • In the OrderSupportAI configuration, go to RAG Sources.
  • Click Create RAG Source.

  • Set:
    • Name: OrderDataType: SQL QuerySQL Query:SELECT
           ‘Order #’ || order_id || ‘ (‘ || order_date || ‘): ‘ ||
           ‘Status: ‘ || order_status || ‘, ‘ ||
           ‘Details: ‘ || details AS order_info
       FROM customer_orders
       WHERE customer_id = NVL(:CURRENT_USER_ID, 101)
       AND (
           1=1 — Return all orders if no specific keywords
           OR UPPER(order_status) LIKE ‘%’ || UPPER(:APEX$AI_LAST_USER_PROMPT) || ‘%’
           OR UPPER(details) LIKE ‘%’ || UPPER(:APEX$AI_LAST_USER_PROMPT) || ‘%’
       )
    • Condition: Leave blank (runs for all prompts), or add a server-side condition like User Prompt Contains with keywords like “order”.

  • Explanation:
    • :CURRENT_USER_ID ties results to the logged-in user.
    • :APEX$AI_LAST_USER_PROMPT dynamically filters based on the user’s question.
  • Save the RAG Source.
Step 5: Create a Page with AI Interaction
  • Create a new Blank Page (e.g., Page 10).

  • Add a Text Field:
    • Name: P10_QUESTION
    • Label: Ask About Your Order

  • Add a Button:
    • Name: SUBMIT_QUESTIONLabel: Get AnswerAction: Submit Page
    • Position: Below P10_QUESTION

  • Add a Display Only item:
    • Name: P10_RESPONSE
    • Label: AI Response

Step 6: Add the “Generate Text with AI” Dynamic Action
  • Right-click the SUBMIT button, select Create Dynamic Action.
  • Set:
  • Name: Generate AI Response
  • Event: Click
  • Selection Type: Button
  • Button: SUBMIT_QUESTION

  • For True Action:
  • Action: Generate Text with AI
  • AI Configuration: OrderSupportAI
  • Input Value Item: P10_QUESTION
  • User Response Item: P10_RESPONSE

  • Save the Dynamic Action.
Step 7: Test Your RAG Feature
  • Log in as a user with customer_id = 101 (set this via :CURRENT_USER_ID in your app’s authentication).

  • Go to Page 10.
  • Enter: What’s the status of my laptop order?
  • Click Submit.
  • Expected Output in P10_RESPONSE: Something like, Your order of 5 laptops (Order ID: 1) is currently Shipped via FedEx.



Sample Use Case: Customer Order Inquiry

Let’s flesh out the use case with all required code and a realistic scenario.

Scenario: A customer wants to know about their recent orders. Instead of manually querying the database, they ask the AI in natural language, and RAG pulls the data to respond.

Complete Code Recap: – Table Setup: See Step 2. – AI Configuration: – System Prompt: You are a customer support assistant. Use the provided order data to answer user questions accurately. – RAG Source SQL: sql     SELECT order_id, order_status, details     FROM customer_orders     WHERE customer_id = :CURRENT_USER_ID     AND UPPER(details) LIKE ‘%’ || UPPER(:APEX$AI_LAST_USER_PROMPT) || ‘%’ – Page Components: – P10_QUESTION: Text Field. – SUBMIT: Button. – P10_RESPONSE: Display Only. – Dynamic Action: – Action: Generate Text with AI – Prompt: &P10_QUESTION. – Target: P10_RESPONSE

Enhancing the Use Case: – Add a PL/SQL Function RAG Source for more complex logic: sql   FUNCTION get_order_summary RETURN CLOB IS     l_summary CLOB;   BEGIN     SELECT LISTAGG(‘Order ‘ || order_id || ‘: ‘ || order_status || ‘ – ‘ || details, CHR(10))     INTO l_summary     FROM customer_orders     WHERE customer_id = :CURRENT_USER_ID;     RETURN l_summary;   END; – Update the RAG Source Type to Function Returning CLOB and use this function. – Test with: Summarize my recent orders. Result: A neat list of all orders for the user.

Tips for APEX Developers

  • Dynamic Filtering: Use :APEX$AI_LAST_USER_PROMPT creatively to match user intent (e.g., parse for keywords like “shipped” or “pending”).
  • Security: Apply row-level security in your SQL to ensure users only see their data.
  • Performance: Limit RAG Source results (e.g., FETCH FIRST 5 ROWS ONLY) to keep AI responses focused.
  • Debugging: Check the AI Assistant logs in Shared Components > AI Logs if responses aren’t as expected.

Why This Matters

With RAG in APEX 24.2, you’re not just building apps—you’re crafting intelligent experiences. Whether it’s customer support, data insights, or dynamic content, RAG lets you harness AI without leaving the low-code comfort of APEX. This guide gives you the foundation; now, experiment with your own data and use cases!

Got questions or want to share your RAG-powered APEX app? Drop a comment below—I’d love to hear from you. Happy coding, APEX devs!


This blog provides a practical, hands-on introduction to RAG in APEX 24.2, complete with a usable example. It’s tailored to engage developers by focusing on real-world application and minimizing fluff, while ensuring all steps and code are clear and actionable. Let me know if you’d like to tweak anything further!

Our Services

Quality services and responsive professional support are the advantages I have with MaxAPEX. THANKS

Evariste BEDINADE

I can’t say enough good things about MaxAPEX, I’ve relied on their hosting services for several years now and they’ve simply never let me down. Whenever issues have arisen, their support team is always incredibly prompt and helpful in their responses. I use their services to manage a portfolio of cloud-based databases and apps, as well as some on-premise management too, and their affordable support has removed so much of the technical overheads and allowed me/my teams to focus on development. If you’re in the market for APEX hosting, simply look no further.

Ryan Byrne

Excellent service, high availability and very good price-value ratio. 100% recommended

Adolfo Blanco

Very nice company, excellent service, very good price-value ratio and amazing amazing support!

Andrei Racila

MaxAPEX Team is Always Ready and on the Time.

Hamzeh Lafi
Spectrum IT Solution

I have asked a lot from MaxAPEX this weekend but as always great work. There is only one Apex hosting company for me and that is MaxAPEX. great work!

Dimitri Lambrou
Feeby, Netherlands

I continue to be impressed by the always excellent support provided by MaxAPEX, thanks again.

Greg Anderson
OrbitQ Ltd, United Kingdom

I appreciate both the quickness and the proactive nature of how my MaxAPEX tickets are resolved. You clearly have a well qualified Oracle staff.

David Bradshaw
Thoroughbred Times, United States

I am always impressed by how much time your support team are prepared to spend on my problems. Well done, as usual!

Stewart Meyer
Natural Resources Wales, United Kingdom

Great. It is is so nice to work with someone who knows their stuff.

Michael J McCann
My American Address Inc, United States

Great response time and very to the point responses. very much appreciated.

Ajith Thomas
Datapoint Solutions Pty Ltd ATF The Thomas Family Trust, Australia

You guys are awesome! Thank you for always providing such wonderful speedy support.

Steve Cockeram
SASHF, South Africa

Gave a great answer and ticket could be closed immediately.

Jacques van der Merwe
Bioforum, South Africa

Excellent,
I always can depend on MaxAPEX for Super Fast Response and to the point response.

Patrick Corbin
Greenup Industries, United States

Excellent response time and got to the solution quickly. Thank you.

IT Service Desk
Skookum Contract Services, United States

Awesome, in a very short timeframe, my problem was resolved, even on Saturday night

Jo Van Eeghem
Solit, Belgium

As soon as I clarified which schema I was having trouble accessing, the connection information was sent to me with a screen shot of exactly how to set it up. Excellent!

Jason Hyler
Rockingham County Schools, United States

Great Job guys, app was working again not long after my request. Thanks

Clive Kellow
Young Control Systems, Australia

I was very satisfied with the way my request was handled in a very timely manner

Ken Robinson
Robinson Process Analytics Aust Pty Ltd, Australia

As always the support is great! Fast and efficient. Thanks with 5 *****

Peter Bachmann
Pebasoft GmbH, Switzerland

We really appreciate the quick and effective response to our issue.

Dan Bowden
Polk County, a political subdivision of the State of Florida, United States

Very quick and adequate response !
Great support, as ever with MaxAPEX.

Dave Maertens
1974, Belgium

Very prompt and to the point which is great, thanks.

Nick Blake
Softlogic, South Africa

The response was amazing! The problem was resolved within a very few minutes of opening the ticket.

Dan Bowden
Polk County, a political subdivision of the State of Florida, United States

Support on this ticket was excellent. The help on this ticket made me feel sure MaxAPEX was an excellent choice.

Dwain Craddock
Tubular Streams, Inc., United States

Quick response to my request, understood my issue and fixed it on the spot. Great work, thanks for your help

robert breuning
unisource solutions, United States

Outstanding response time! He handled this request quickly and completely.

Excellent support. Thank you

Dan Bowden
Polk County, a political subdivision of the State of Florida, United States

My query was well understood and was answered very fast and with all the clarity needed. As always, excellent service from MaxAPEX. Thank you!

Daniel Bosman
Mosberger EDV AG, Switzerland

Like always, your support is always best in class. I appreciate this.

Peter Bachmann
Pebasoft GmbH, Switzerland

Just did a great job – thanks. Please keep it up!

Paul Joyce
Self, Ireland

It was a easy task, but what I really appreciate is that the issue was solved in minutes. Keep on the good work!

Aljaž Mali
THE RIGHT THING Solutions, d.o.o.

It is solved now, very happy with the support. Keep up the good work.

Michel Gjaltema
Casiro, Netherlands

I think it is great how MaxAPEX responses to my tickets, even in the evening and during the weekends.

Harm Harmenzon
Burger Breedband, Netherlands

All of the guys provided great support for our server migration. We appreciate the hard work and dedication.

Mauro Juarez
Distribuidora Zucchi, Argentina

Team was able to provide me with solutions to my problem, of which i am very grateful for. Well done!

Babatunde Lasisi
FerraHub, South Africa

Great support, gave me information to fix a performance issue.

Pablo de Paola
Data4Lives, Brazil

We are very happy to using max apex hosting. they are support very nice and prompt. i recommend APEX user to use their hosting

Aaroz.com
Idea Infintiy BD Limited, Bangladesh

MaxAPEX support is very good. I have never experienced a situation where they have not been able to help or where the work was not completed very quickly.

Richard Pickett
United Kingdom

Excellent service, full cooperation of support staff and good cloud performance.

Dario
Giesse software, Italy

In mid-2013 I started looking for a hosting service that could house my project of serving small businesses with specialized system solutions developed on Oracle Apex that meet the need of this market share. I found Maxapex and since then we have established this partnership with excellent cost benefit and high quality services available. Thank you Maxapex for the excellent services provided over these 6 years.

Luiz Sabenca
Prismus Systems, Brazil

I’m glad I decided to work with you. I never have any problem at all. Thanks so much for doing a great job!

Gordana Bobinac
IT-Apex4u, Serbia

I Have been using Maxapex Service since couple of years. The most thing that attracted me, their instance support and response at any time. Hope to continue this support in future in more improve way.

Vobon, Bangladesh

We appreciate the incredible support MAXAPEX team have provided for us.
We got help with things like that linux configuration, establishing odbc connection that are not strictly related to server hosting. This is the best value for money service on this area.

David Pataki
Enrol Consulting Kft, Hungary

Maxapex is the perfect choice for hosting Oracle Apex. The support service is speedy and responsive. We did not have a situation where they could not help. You can quickly change your tariff plan to the most suitable one. Server uptime is excellent. We did not have a situation when our business was suspended.

Ed Zakabluk
Technosvit, Ukraine

MaxAPEX , really facilitate my start with apex by making it Jump , the team is very helpful and understanding people , ‘I’ve passed more than 3 years with max apex and i feel happy with their support and their services

Haythem Mousa
Smart Orbits, United Arab Emirates

Hi, my name is Roberto Párraga. I’m developer in Oracle Apex with Oracle Database XE.
My expririence with MaxAPEX is successfully, because helpme to developer and deploy successfully my applications.
The technical support is excellent because my questions got quicly responses.
The stability of the hosting service and the continuous it’s wanderfull, 24/7.
In abstract, I recommend MaxAPEX Hosting for deploy applications developed in Oracle ApeX.

ROBERTO ANTONIO PATRRAGA ZAMBRANO
MONSERRATE ALAVA DE GONZÁLEZ, Ecuador

We found MaxAPEX’s technical support team very cooperative, quick & responsive. Hosting services are very much reliable, we never even think about switching to another company.

Ahmed Bilal
Orbit Systems, Pakistan

We have been using Oracle APEX hosting from MaxAPEX for almost 7 years now. I can recommend it as the service, level of expertise and support is really good. We host several Apex web applications with MaxAPEX for our customers that are mainly schools. The users and schools are depending on our Apex Apps with MaxAPEX to execute quality checks which are needed by the Ducth law. An other web app helps teachers during class to track, help and administrate students. As you can imagine it is very important for us that the MaxAPEX servers are fast and reliable which they are. Keep up the good work MaxAPEX.

Michel
Feeby, Netherland

One of the best oracle apex hosting i have ever used. You guys rock, very fast and active when it comes to ticket solving. Keeo up the good work. I have recomended to many Colleagues and customer about maxapex.

Mark Trading Kuwait
B2IK, Kuwait

We looked for a company who offers APEX hosting about 2 years ago. We found MaxAPEX and were suprised about the portfolio and the pricing. So we started to use their platform with our CRM system developed on Oracle APEX.
We rate the availability, the update policy and the speed/quality of the support with five stars.
Thank you very much!
Steven Ponndorf

Steven Ponndorf
Harmonyliving, Germany

Excellent company!

Great service! are fast and efficient … Congratulations!

Denis Araujo
DESOSP SERVIÇOS EM INFORMATICA, BRAZIL

I am a MaxAPEX customer for several years now. My company inventory, stock control and invoicing system done using Oracle APEX is hosted with MaxAPEX. These guys have the best support system and a very reliable up-time. Every upgrade and maintenance is always notified in advance, so our IT team is aware to let the other team members know. My 10/10 recommendation goes to MaxAPEX!!!

Shaminda Samaratunge
Ananda Miners (Pvt) Ltd, Sri Lanka

I have been using MaxAPex for several years, in various configurations (shared, dedicated etc) and I have never had any issues with the serivce. Further, I find the support very responsive and very good. I have no issues with using MaxAPEX as a platform for my live customers. Using this service just takes away so much Oracle Admin headache etc. I would highly recommend MaxAPEX as a hosting partner for any Apex Applications.

Paul Joyce
Ireland

As part of a volunteer organisation, I was looking for a service to help solve a big problem for us which was the hours of admin involved in running a local community centre. Services are affordable and scalable and responses to my questions were swift and the support team have been amazing in helping me get what I needed. Upgrades are managed and as an Oracle partner, these guys ensure we are running the latest and greatest and soon as it’s available. Overall I have been very happy with performance too as well as the option to host within the UK. I have managed in a very short time to release an app to our community where most of the admin is now done by them, we’ve set up over 800 events this year, cut invoicing down from one day to 15 mins per quarter and automated several other processes. We have integrated with Stripe and Twilio too!

Adam Howard
The Parks Community Association, United Kingdom

We have been working with MAXAPEX for approximately 5 years. We have 3 mission critical applications operating in their infrastructure. The service offered by MAXAPEX has been optimal for our needs, and has allowed us to grow as we have required. Their support is excellent, and has allowed us to really concentrate on satisfying the needs of our business.

Juan Carlos Garcia Iza
Macrotics SAS, Colombia

I have used MaxAPEX for over ten years now and found them to be both practical and extremely reliable. Equally impressive is their competent and timely response to my occasional questions and service tickets.

As an APEX developer, having full control of an entire Oracle XE instance gives me lots of options and because it is professionally supported by MaxAPEX I never have to worry about Oracle upgrades or new versions. I also appreciate the fact that it is physically located in a data center with fast Internet access both in and out. This is something a small company like mine cannot easily do on our own.

Thanks, MaxAPEX, for providing this valuable service at a cost I can afford.

Tony
Konoso LLC, USA

I have been a MaxAPEX customer since 2015. It is a very stable, reliable, and fast platform. The support is excellent and very timely. It is always updated to the latest versions. In MaxAPEX we have hosted all our systems and we are extremely satisfied, I highly recommend them.

Adolfo Blanco
BLEICO, C.A, Venezuela
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x