Skip to content

DB2: Fetch first row only gives exception (also with UR problem) #615

Closed
@stonerich

Description

@stonerich

Actual Behavior

This code gives ParseException:

	String str = 
			"select distinct T1.A  " 
			+" from  T2 join  T1  on (T2.B = T1.C)  "
		    + " fetch first row only with UR";
			//  + "fetch first 3 rows only with UR";
	Statement stmt1 = CCJSqlParserUtil.parse(str);

Exception:

Exception in thread "main" net.sf.jsqlparser.JSQLParserException
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:55)
at csn.mier.test.sqlparser.App.main(App.java:56)
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "row" "ROW"
at line 1, column 74.

Was expecting one of:

"?"
<S_LONG>

at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:18047)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:17900)

Note that "FETCH FIRST 1 ROW ONLY" works, but then adding "WITH UR" gives another exception.

net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "with" "WITH"
    at line 1, column 85.

Was expecting one of:

    ";"
    "EXCEPT"
    "FOR"
    "INTERSECT"
    "MINUS"
    "ORDER"
    "UNION"
    <EOF>

	at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:18047)
	at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:17900)
	at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:91)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:53)

Expected Behavior

Not get an exception

Steps to Reproduce the Problem

Run the code above

Specifications

  • Version: 1.2
  • Platform: Windows
  • Subsystem: NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions