SQL Parsing Error with MySQL and ODBC Connection

Avatar
  • updated
  • Answered

Hello


While using Active Query Builder with a MySQL database via an ODBC connection; I faced  an SQL parsing error. The issue arises when attempting to parse a query containing a WITH clause for Common Table Expressions (CTEs). The parser fails to recognize the WITH keyword and throws an error.

Environment details:

  • Database Server: MySQL 8.0.32
  • Connection Type: ODBC
  • Example Query:
    WITH cte_example AS (
        SELECT id, name FROM users WHERE active = 1
    )
    SELECT * FROM cte_example;
    


Steps to reproduce:

  1. Connect to a MySQL database using an ODBC driver.
  2. Attempt to parse the provided SQL query containing a WITH clause.


The parser should correctly recognize and process the WITH clause and subsequent query.
An error is returned indicating that the WITH keyword is not recognized. I have checked https://www.activequerybuilder.com/product_api.html.MongoDB documentation guide but still need advice . 

Please advise if there is a workaround / configuration setting that supports CTEs in this scenario.

Thank you !

Avatar
Andrey Zavyalov, PM
  • Answered

Hello,


On choosing the ODBC or OLE DB (generic) connection type, you should set the SQL syntax for the underlying database server manually or rely on the autodetection routine.

Wizard:

Image 2058


Connection Properties form:

Image 2059