question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing declare statements

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
wumpzcommented, Aug 8, 2019

Could you check it. I implemented all of your test sql types.

0reactions
wumpzcommented, Aug 11, 2019

You were right. It was only at the first sight similar to set. However thx for using Jsqlparser. Cheers Tobias

Read more comments on GitHub >

github_iconTop Results From Across the Web

The PARSEONLY SQL command overview and examples
The PARSEONLY statement allows only the Parse phase for T-SQL. It has the following options: SET PARSEONLY ON: We can specify this statement...
Read more >
SQL Server: Parse error when declaring table - Stack Overflow
This declares a table with one column, whose name is date and whose type is date . Here is a db<>fiddle.
Read more >
Parse (Database Engine) - SQL Server - Microsoft Learn
Parse is called implicitly when a conversion from a string type to hierarchyid occurs. Acts as the opposite of ToString.
Read more >
How to Parse Strings Like a Pro Using SQL SUBSTRING ...
The article discusses string parsing and how SQL substring function can help in achieving this. It presents unique examples both in SQL ...
Read more >
PARSE procedure - Parse an SQL statement - IBM
The PARSE procedure parses an SQL statement. If the SQL command is a DDL command, it is immediately executed and does not require...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found