{"id":53,"date":"2010-01-23T08:42:58","date_gmt":"2010-01-23T13:42:58","guid":{"rendered":"http:\/\/www.dpriver.com\/blog\/?p=53"},"modified":"2011-09-26T21:50:05","modified_gmt":"2011-09-27T02:50:05","slug":"general-sql-parser-java-version-0-1","status":"publish","type":"post","link":"https:\/\/www.dpriver.com\/blog\/2010\/01\/general-sql-parser-java-version-0-1\/","title":{"rendered":"General SQL Parser Java Version 0.1"},"content":{"rendered":"

I’m very excited to let you know that General SQL Parser Java Version 0.1<\/a> was finally released in 01-22-2010. This is the first release of general sql parser java version.<\/p>\n

This SQL parser had a solid infrastructure now, with the ability to parse most SQL statements used in Access, SQL Server, DB2, MySQL and Oracle, including nested queries, complex join clause, stored procedure, trigger, function, PLSQL packages and etc. Syntax check is the most basic feature which is available once I finished the infrastructure of this SQL parser. But I’m too busy to add more features like\u00a0 SQL formatter, fetch table and column information of SQL statement, modify and rebuild SQL, query tree structure in xml(Those features are already available in .NET and VCL version<\/a>).\u00a0 So SQL syntax check is the main feature of this release, and I will add more features(some may not listed above) one by one based on requests from users. If you want to use this SQL parser in your project or product, please don’t hesitate to contact me(info@sqlparser.com) for further information about this SQL parser.<\/p>\n

Ok, Here are some detailed information about this release.<\/p>\n

All supported SQL statements are listed in those packages:<\/p>\n

gudusoft.gsqlparser.stmt <\/a><\/p>\n

gudusoft.gsqlparser.stmt.db2<\/a><\/p>\n

gudusoft.gsqlparser.stmt.mysql<\/a><\/p>\n

gudusoft.gsqlparser.stmt.mssql<\/a><\/p>\n

gudusoft.gsqlparser.stmt.oracle<\/a><\/p>\n

This SQL Parser can be used in several ways such as:<\/p>\n

1. Check SQL syntax of Access, Db2, MySQL, SQL Server, Oracle dialect. Give detailed error message if found any syntax error in SQL script.<\/p>\n

2. Get all SQL statements with type and fragment information in SQL script.<\/p>\n

select last_name,job_id,salary from employees
\nwhere job_id=(select job_id
\nfrom employees
\nwhere employee_id=141)
\nand salary >
\n(select salary
\nfrom employees
\nwhere employee_id=141);<\/p>\n

insert into emp e1 (e1.lastname,job) values(scott,10);<\/p>\n

delete from department
\nwhere department_name = ‘Finance’;<\/p>\n

update employees
\nset job_id = (select job_id
\nfrom employees
\nwhere employee_id = 205),
\nsalary = (select salary from employees
\nwhere employee_id = 205)
\nwhere employee_id = 114;<\/p>\n

SQL parser can analyze this script, and list 4 individual statement like this:<\/p>\n

sstselect
\n=========
\nselect last_name,job_id,salary from employees
\nwhere job_id=(select job_id
\nfrom employees
\nwhere employee_id=141)
\nand salary >
\n(select salary
\nfrom employees
\nwhere employee_id=141);<\/p>\n

sstinsert
\n=========
\ninsert into emp e1 (e1.lastname,job) values(scott,10);<\/p>\n

sstdelete
\n=========
\ndelete from department
\nwhere department_name = ‘Finance’;<\/p>\n

sstupdate
\n=========
\nupdate employees
\nset job_id = (select job_id
\nfrom employees
\nwhere employee_id = 205),
\nsalary = (select salary from employees
\nwhere employee_id = 205)
\nwhere employee_id = 114;<\/p>\n

3. Tokenize SQL script, easy to check identifier, keyword, operator, constants, comment and special characters.<\/p>\n

insert into emp e1 (e1.lastname,job) values(scott,10);<\/p>\n

After tokenize this script, SQL parser will generate output like this:<\/p>\n

ttkeyword insert
\nttwhitespace
\nttkeyword into
\nttwhitespace
\nttidentifier emp
\nttwhitespace
\nttidentifier e1
\nttwhitespace
\nttleftparenthesis (
\nttidentifier e1
\nttperiod .
\nttidentifier lastname
\nttcomma ,
\nttidentifier job
\nttrightparenthesis )
\nttwhitespace
\nttkeyword values
\nttleftparenthesis (
\nttidentifier scott
\nttcomma ,
\nttnumber 10
\nttrightparenthesis )
\nttsemicolon ;<\/p>\n

If you like to have a try of this library, you can download it here:<\/p>\n

http:\/\/www.sqlparser.com\/download.php
\n<\/a><\/p>\n

What kind of\u00a0 features will be\u00a0 in next release?<\/p>\n

I will like to add feature to fetch table and column in select\/delete\/insert\/update statement in next release, hopefully, this feature will be available in the end of Feb 2010.<\/p>\n

If you have any suggestions or features request about next release, feel free to contact me(info@sqlparser.com), your feedback is always welcome.<\/p>\n","protected":false},"excerpt":{"rendered":"

I’m very excited to let you know that General SQL Parser Java Version 0.1 was finally released in 01-22-2010. This is the first release of general sql parser java version. This SQL parser had a solid infrastructure now, with the ability to parse most SQL statements used in Access, SQL Server, DB2, MySQL and Oracle, including nested queries, complex join clause, stored procedure, trigger, function, PLSQL packages and etc. Syntax check is the most basic feature which is available once I finished the infrastructure of this SQL parser. But I’m too busy to add more features like\u00a0 SQL formatter, fetch\u2026<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14,15],"tags":[],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":5}},"yoast_head":"\nGeneral SQL Parser Java Version 0.1<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n