views:

193

answers:

2

I want to parse the SQL code of a file .sql using C#.

I want determinate Syntax Check of a file sql, specifically Insert, Update and Delete statements.

Specifically is there any parser freely available which can parse the SQL code in C# .NET ? better is freeware, source code included, and easy use.

I use Oracle

+2  A: 

You can try with ANTLR.
On grammar page you will find several grammars related to Oracle.

Unrelated, is there a way to just "Prepare" statement without execution? That way you could have Oracle check syntax and then catch eventual errors in your code. This will help you skip duplicating functionality already present in Oracle. Not to mention problem of handling changes between different versions of Oracle.

Edit:
Re comment about code examples: I used ANTLR briefly and I had hard time finding code examples on internet. Main source I found was examples from ANTLR download page. Now I see that Terence Parr, author of ANTLR, published new book and that accompanying source code contains more ANTLR examples.

Since you don't have much experience with ANTLR, may I, again, suggest that you try another approach, since this is fairly complex area and needs considerable learning effort to get you started. At least, that was my experience.

zendar
thx, mr. Zendar; any sample application in .NEt -with source code if is possible- that use AntLR ??
alhambraeidos
A: 

General SQL Parser is what you need, but it's not freeware, and not open source. You can find more information here: http://www.sqlparser.com/

James
any other freeware or open source ?
alhambraeidos