New System Validates NL2SQL Queries for Oracle Databases

Sanjay Mishra, Divya Chukkapalli, Ganesh R. Naik· July 28, 2026 View original

Summary

Schema-Aware Localisation (SAL) is a middleware layer that improves the reliability of natural language to SQL (NL2SQL) generation for Oracle databases by grounding LLM-generated queries against live schema information and validating references. It significantly reduces execution failures and hallucinations without requiring model retraining.

Large language models often struggle to generate accurate SQL for real-world enterprise Oracle databases, frequently producing invalid column or alias references that lead to execution errors. This issue stems from a lack of schema grounding, meaning the models don't inherently know which tables and columns actually exist. A new middleware layer, Schema-Aware Localisation (SAL), addresses this by dynamically querying Oracle's catalog to build a live schema map. This map is then injected into the LLM prompt, providing ground-truth context. Additionally, a Hallucination Index (Hidx) validates all generated alias and column references against the live catalog, automatically correcting common errors or triggering structured retries with specific feedback. Evaluations using GPT-4o-mini on 500 TPC-H questions against an Oracle Autonomous Database showed SAL dramatically improved execution-grounded truth (EGT) from 2.2% to 62.6%, while reducing execution failures from 97.6% to 2.6%. This improvement was achieved without any manual schema curation or model retraining, highlighting its practical applicability.

Why it matters

This research offers a practical solution to a major hurdle in deploying NL2SQL systems for enterprise databases, significantly improving reliability and reducing the need for manual intervention. Professionals can leverage this to make LLM-generated SQL more robust and trustworthy in production environments.

How to implement this in your domain

  1. 1Integrate SAL as a middleware layer between your NL2SQL application and Oracle database.
  2. 2Configure SAL to access Oracle's USER_TAB_COLUMNS catalog for live schema mapping.
  3. 3Implement the Hallucination Index (Hidx) to validate and correct generated SQL queries before execution.
  4. 4Monitor the performance and error rates of NL2SQL queries to quantify the benefits of SAL.
  5. 5Provide structured feedback from Hidx to the LLM for iterative improvement in query generation.

Who benefits

BFSIHealthcareGovernmentRetailManufacturing

Key takeaways

  • LLMs often hallucinate SQL elements when generating queries for complex enterprise databases.
  • Schema-Aware Localisation (SAL) provides live schema grounding to improve NL2SQL accuracy.
  • The Hallucination Index (Hidx) validates and corrects generated SQL, reducing execution errors.
  • SAL significantly boosts NL2SQL reliability for Oracle databases without model retraining.

Original post by Sanjay Mishra, Divya Chukkapalli, Ganesh R. Naik

"arXiv:2607.22572v1 Announce Type: new Abstract: Large language models can generate fluent SQL from natural language, but on real enterprise Oracle databases they frequently fail at execution time: columns and aliases are hallucinated and dialect-specific syntax is missed, leading…"

View on X

Originally posted by Sanjay Mishra, Divya Chukkapalli, Ganesh R. Naik on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses