This study addresses the growing need for reliable data access systems by focusing on the validation of SQL queries generated from natural language using a Text-to-SQL approach. The primary objective of this research is to evaluate the effectiveness of a rule-based SQL grammar validator in detecting syntactic errors and improving the overall quality of queries generated by Large Language Models (LLMs), particularly in the context of Indonesian language input. The research methodology follows a structured process, including literature review, dataset construction, system design, implementation, and performance evaluation. Two datasets were developed: one for validating the grammar checker using both valid and invalid SQL queries, and another for evaluating the Text-to-SQL system. The validator was implemented using a rule-based system with grammar defined in EBNF and executed using forward chaining inference. The results indicate that the system achieves high performance, with an accuracy of 0.909, precision of 0.857, recall of 1.000, and F1-score of 0.923. The validator successfully identifies common structural errors such as missing table references and incomplete JOIN clauses. However, some limitations remain in detecting more complex syntax patterns. Overall, the integration of the grammar checker significantly enhances the reliability of SQL query generation. In conclusion, the proposed system demonstrates strong effectiveness in syntax validation and contributes to improving the robustness of Text-to-SQL systems.
Copyrights © 2026