Helpful Information
 
 
Category: Development Software
need an sql parser

Honest to god, I searched the internet for a good hour and half and found nothing.

Does anyone know of an sql parser that can validate an sql statement? It doesn't have to be in php.

I remember seeing one here before and can't find it now.

Moved to Development Software.

Chibiguy, please keep your posts on-topic, thanks.

my fault.

Here are a few Perl parsers:
http://search.cpan.org/~jzucker/SQL-Statement-1.005/lib/SQL/Parser.pm
http://search.cpan.org/~jzucker/SQL-Statement-1.005/lib/SQL/Statement.pm
http://sqlfairy.sourceforge.net/
http://sourceforge.net/projects/sqlfairy/

A Delphi parser is here:
http://sourceforge.net/projects/gasqlparser/

And a description of the SQL language can be found here:
http://www.netaktive.com/article.php3?id_article=11
http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt
http://www.contrib.andrew.cmu.edu/~shadow/sql/sql2bnf.aug92.txt

The O'Reilly Lex & Yacc book contains the implementation of an SQL parser, but that is probably not what you want, just thought I would mention it.

SQL parser is server specific. the one works with Oracle may not work with MS SQLServer, Sybase, or MySQL

You can try a workaround, send an EPLAIN query to the database and watch the response.
On Oracle there is a php function ociparse (http://www.php.net/manual/en/function.ociparse.php) which is said to
It returns the statement identity if the query is valid, FALSE if not
Hope this helps!

I thought that I'd mention that I did finally create a parser ...

http://txtsql.dotgeek.org and click "development" link at the top... it's in two files - txtSQL.tokenizer.php and txtSQL.lexer.php

Tell me what you guys think...

ChibiGuy, do you still have that parser available? The link above is dead.

Thanks!

<URL> and click "development" link at the top... it's in two files - txtSQL.tokenizer.php and txtSQL.lexer.php

The link is dead. Do you know if there's another link?

Just curious, do you really want a generic SQL parser?
They are mostly useless. Nobody writes SQL. Or perhaps very, very few people write SQL. They write in sql for some implementation such as MySql, SQL Server, Oracle, etc.

While it is technically possible to use pure SQL, each package adds some cool stuff that makes your life easier, and so most humans fall into the trap of using the extensions.

Just curious, do you really want a generic SQL parser?
They are mostly useless. Nobody writes SQL. Or perhaps very, very few people write SQL. They write in sql for some implementation such as MySql, SQL Server, Oracle, etc.

While it is technically possible to use pure SQL, each package adds some cool stuff that makes your life easier, and so most humans fall into the trap of using the extensions.

Yes, I do. While its true that people use different features, most SQL is in fact portable. Take just about any SELECT, UPDATE, or INSERT statement. They are going to work most of the time on any platform as long as the correct objects are in the database.

The link is dead. Do you know if there's another link?Here (http://www.txtsql.com/index.php?module=dev) it is










privacy (GDPR)