Skip to content

MS SQL Server 2012 specific SET statement #1984

Description

@1037475482

Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "on" "ON"
at line 1, column 47.

Was expecting one of:

"&"
","
"::"
";"
"<<"
">>"
"COLLATE"
"["
"^"
"|"
<EOF>

at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:31468)
at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:31301)
at net.sf.jsqlparser.parser.CCJSqlParser.Statements(CCJSqlParser.java:903)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:213)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:203)
at com.baomidou.mybatisplus.extension.parser.JsqlParserGlobal.parseStatements(JsqlParserGlobal.java:51)
at com.baomidou.mybatisplus.extension.parser.JsqlParserSupport.parserMulti(JsqlParserSupport.java:62)
... 39 common frames omitted

Activity

  1. manticore-projects commented on Mar 31, 2024

    @manticore-projects
    Contributor

    Greetings.

    Without at least a Sample SQL there is nothing I can do for you.

  2. 1037475482 commented on Mar 31, 2024

    @1037475482
    Author

    For example:

    SET IDENTITY_INSERT tb_inter_d2v_transfer on;
    INSERT INTO tb_inter_d2v_transfer (
    SEQID,
    TASKID,
    PALNO,
    BOXCODE,
    OPTYPE,
    DETADDRE,
    ERRORCODE,
    FLAG,
    SENDTIME,
    WHSEID,
    TEMP1,
    TEMP2,
    TEMP3,
    TEMP4,
    TEMP5
    ) values

    (
    #{item.SEQID},
    #{item.TASKID},
    #{item.PALNO},
    #{item.BOXCODE},
    #{item.OPTYPE},
    #{item.DETADDRE},
    #{item.ERRORCODE},
    #{item.FLAG},
    #{item.SENDTIME},
    #{item.WHSEID},
    #{item.TEMP1},
    #{item.TEMP2},
    #{item.TEMP3},
    #{item.TEMP4},
    #{item.TEMP5}
    )

  3. manticore-projects commented on Mar 31, 2024

    @manticore-projects
    Contributor

    You are showing 2 statements:

    -- this syntax is not supported
    SET IDENTITY_INSERT tb_inter_d2v_transfer on;

    Supported SET syntax is shown here: https://manticore-projects.com/JSQLParser/syntax_snapshot.html#set
    If you need more than this you would need to provide or sponsor an implementation.

    -- INSERT is supported
    INSERT INTO tb_inter_d2v_transfer (
        seqid
        , taskid
        , palno
        , boxcode
        , optype
        , detaddre
        , errorcode
        , flag
        , sendtime
        , whseid
        , temp1
        , temp2
        , temp3
        , temp4
        , temp5 )
    VALUES (    item.seqid, item.taskid, item.palno
                , item.boxcode, item.optype, item.detaddre
                , item.errorcode, item.flag, item.sendtime
                , item.whseid, item.temp1, item.temp2
                , item.temp3, item.temp4, item.temp5 )
    ;
  4. changed the title [-][BUG] JSQLParser Version : 4.6 RDBMS:Microsoft SQL Server 2012 (SP4) (KB4018073) - 11.0.7001.0 (X64) Aug 15 2017 10:23:29 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.3 <X64> (Build 17763: ) (Hypervisor) [/-] [+]MS SQL Server 2012 specific `SET` statement[/+] on Mar 31, 2024
  5. 1037475482 commented on Mar 31, 2024

    @1037475482
    Author

    Is there a version that supports SET IDENTITY_INSERT tb_inter_d2v_transfer on;

  6. manticore-projects commented on Mar 31, 2024

    @manticore-projects
    Contributor

    Unfortunately not, the SET statement will have to be amended for the MS SQL Server specific syntax.

  7. manticore-projects commented on Apr 18, 2024

    @manticore-projects
    Contributor

    With latest JSQLParser 4.10 Snapshot, you can use UnsupportedStatement as shown below:

            String sqlStr = "SET IDENTITY_INSERT tb_inter_d2v_transfer on";
            
            Statement statement = CCJSqlParserUtil.parse(sqlStr,
                    parser -> parser.withUnsupportedStatements(true));
            Assertions.assertInstanceOf(UnsupportedStatement.class, statement);
    
            TestUtils.assertStatementCanBeDeparsedAs(statement, sqlStr, true);
  8. added a commit that references this issue on Apr 24, 2024
    063d244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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