JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

Cannot use MySQL user variables after INTO clause

Open sivaraam opened this issue 6 years ago • 0 comments

Describe the bug Using MySQL user variables after the INTO clause in a SELECT is a perfectly valid MySQL query. But the parse is unable to parse such a query.

To Reproduce Steps to reproduce the behavior:

  1. Example SQL:
    SELECT COUNT(*) INTO @countTotal FROM employee;
    
  2. Parsing this SQL using JSqlParser with this statements:
        try {
            Statement userVariableAfterInto =
                    CCJSqlParserUtil.parse("SELECT COUNT(*) INTO @countTotal FROM employee;");
        } catch (JSQLParserException e) {
            e.printStackTrace();
        }
    
  3. Exception
    Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "@" "@"
        at line 1, column 22.
    
    Was expecting one of:
    
    	"ACTION"
        "ANY"
        "BYTE"
        "CASCADE"
    

Expected behavior It should be possible to use MySQL user variables after the INTO clause of the SELECT query.

System

  • Database you are using: MySQL
  • Java Version: 11.0.3
  • JSqlParser version: 3.0

sivaraam avatar Sep 24 '19 11:09 sivaraam