0

My statement is

new_call.cdctype=goal.cdctype

When I call the method CCJSqlParser.SQLCondition() on this, I get an exception saying

Encountered " "=" "= "" at line 1, column 17.
Was expecting one of:
    "NOT" ...
    "LIKE" ...
    "ILIKE" ...
    "NOT" ...
    "NOT" ...

Any insight on why this happens? I am checking join conditions and I think that this is an appropriate expression for join condition.

Code:

String sql = "new_call.cdctype=goal.cdctype";
CCJSqlParser parser = new CCJSqlParser(new StringReader(sql));
    String errorMsg=null;
    try {
        parser.SQLCondition();
    } catch (ParseException e) {
        errorMsg=e.getMessage();
    }
    return errorMsg;

1 Answers1

1

If you dig a bit deeper into JSqlParsers grammer you will find, that a SQLCondition is only one of:

  • in
  • between
  • isnull
  • exists
  • like expression.

You specified a so called RegularCondition.

Here are two methods to parse your condition:

//Shortcut
Expression parseCondExpression = CCJSqlParserUtil.parseCondExpression("new_call.cdctype=goal.cdctype");
System.out.println(parseCondExpression);

//from issue
String sql = "new_call.cdctype=goal.cdctype";
CCJSqlParser parser = new CCJSqlParser(new StringProvider(sql));
try {
    parser.RegularCondition();
} catch (ParseException e) {
    e.printStackTrace();
}

By the way I am using JSqlParser V1.2. Your version seems a bit older, because the constructor parameter of the parser is now a Provider.

wumpz
  • 8,257
  • 3
  • 30
  • 25