Parsing declare statements
See original GitHub issueAre 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:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Could you check it. I implemented all of your test sql types.
You were right. It was only at the first sight similar to set. However thx for using Jsqlparser. Cheers Tobias