You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static void main(String[] args) {
String sql = "SELECT STUFF((SELECT ',' + name FROM class order by id FOR XML PATH('')),1,1,'') AS names from " +
"users";
try {
Statement statement = CCJSqlParserUtil.parse(sql);
} catch (JSQLParserException e) {
throw new RuntimeException(e);
}
}
CCJSqlParserUtil解析sql错误,错误信息如下
as expecting one of:
<EOF>
<ST_SEMICOLON>
at com.aciplaw.patas.operation.service.impl.CaseInfoServiceImpl.main(CaseInfoServiceImpl.java:1154)
Caused by: net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
at line 1, column 13.
Was expecting one of:
<EOF>
<ST_SEMICOLON>
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:352)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:125)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:91)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:64)
at com.aciplaw.patas.operation.service.impl.CaseInfoServiceImpl.main(CaseInfoServiceImpl.java:1152)
Caused by: java.util.concurrent.ExecutionException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
at line 1, column 13.
Was expecting one of:
<EOF>
<ST_SEMICOLON>
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:205)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:345)
... 4 more
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
at line 1, column 13.
Was expecting one of:
<EOF>
<ST_SEMICOLON>
at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:48520)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:48341)
at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:345)
at net.sf.jsqlparser.parser.CCJSqlParserUtil$1.call(CCJSqlParserUtil.java:341)
at net.sf.jsqlparser.parser.CCJSqlParserUtil$1.call(CCJSqlParserUtil.java:338)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)
如果去掉order by ,解析就会正确,程序如何
public static void main(String[] args) {
String sql = "SELECT STUFF((SELECT ',' + name FROM class FOR XML PATH('')),1,1,'') AS names from " +
"users";
try {
Statement statement = CCJSqlParserUtil.parse(sql);
} catch (JSQLParserException e) {
throw new RuntimeException(e);
}
}
估计是 CCJSqlParser 类解析时出错,应该时一个bug,期望下个版本可以解决
The text was updated successfully, but these errors were encountered:
@manticore-projects
When the STUFF function is used in combination with FOR XML
PATH, it can implement a function similar to GROUP CONCAT, co
mbining strings in multiple rows into one string. This is very uset
ul when you need to merge the content of multiple lines into on
e result.
can you supported this function?????????
SQL Example:
public static void main(String[] args) {
String sql = "SELECT STUFF((SELECT ',' + name FROM class order by id FOR XML PATH('')),1,1,'') AS names from " +
"users";
try {
Statement statement = CCJSqlParserUtil.parse(sql);
} catch (JSQLParserException e) {
throw new RuntimeException(e);
}
}
CCJSqlParserUtil解析sql错误,错误信息如下
as expecting one of:
Caused by: net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
at line 1, column 13.
Was expecting one of:
Caused by: java.util.concurrent.ExecutionException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
at line 1, column 13.
Was expecting one of:
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
at line 1, column 13.
Was expecting one of:
如果去掉order by ,解析就会正确,程序如何
public static void main(String[] args) {
String sql = "SELECT STUFF((SELECT ',' + name FROM class FOR XML PATH('')),1,1,'') AS names from " +
"users";
try {
Statement statement = CCJSqlParserUtil.parse(sql);
} catch (JSQLParserException e) {
throw new RuntimeException(e);
}
}
估计是 CCJSqlParser 类解析时出错,应该时一个bug,期望下个版本可以解决
The text was updated successfully, but these errors were encountered: