Skip to content

Parsing declare statements #828

@perNyfelt

Description

@perNyfelt

Are there any plans to support T-SQL declare statements?
Would a pull request to add support for that be welcome?

Actual Behavior

StringBuffer sql = new StringBuffer()
        .append("declare @extractDate date = (select max(dateExtracted) from creditInformation);\n")
        .append("declare @ciTable table (ciId numeric(19,0));\n")
        .append("insert into @ciTable ")
        .append("select surrogateId as ciId\n")
        .append("from creditInformation\n")
        .append("where dateExtracted = @extractDate");

Statements stmt = CCJSqlParserUtil.parseStatements(sql.toString());

Thows:
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "declare" <S_IDENTIFIER>

Expected Behavior

should be parsed into 3 statements.

Specifications

  • Version:
    <dependency>
      <groupId>com.github.jsqlparser</groupId>
      <artifactId>jsqlparser</artifactId>
      <version>2.1</version>
    </dependency>
  • Platform: Windows 10
  • Subsystem: Java 8

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