Notes26aiRAGPL/SQL

A full RAG pipeline in Oracle, without leaving SQL

One package, DBMS_VECTOR_CHAIN, takes a document from BLOB to grounded answer: extract, chunk, embed, search, generate.

No Python glue and no separate vector store. In Oracle AI Database 26ai, one PL/SQL package, DBMS_VECTOR_CHAIN, plus plain SQL covers the whole retrieval-augmented generation flow. Ulrike Schwinn from Oracle walks through it end to end.

The five steps

  1. UTL_TO_TEXT turns a document stored as a BLOB (or CLOB) into plain text.
  2. UTL_TO_CHUNKS splits it. by defaults to words, max to 100, split to recursively; overlap is 0 by default and can be 5–20% of max.
  3. UTL_TO_EMBEDDINGS creates the vectors. With the default "provider":"database" it calls an ONNX embedding model you loaded into the database.
  4. VECTOR_DISTANCE(..., COSINE) finds the chunks closest to the question.
  5. UTL_TO_GENERATE_TEXT sends the question and those chunks to an LLM and returns the answer. This step always calls an external provider over REST, so it needs a credential and a network ACL.

Two tips

  • Don't trust the first chunk size. Try a few max/overlap combinations and compare the answers.
  • Tell the LLM to answer only from the supplied context and to cite chunk IDs, so every answer can be checked.

For APEX teams, a "chat with our documents" page becomes a PL/SQL job. Sources: From Raw to RAG with DBMS_VECTOR_CHAIN and the DBMS_VECTOR_CHAIN reference.

Get the Oracle + AI digest

One email when a new tested guide, template or APEX release note lands — English or Arabic. No spam; unsubscribe anytime.