My guess is that the H2 parser is a bit to dependent on other stuff be
usabe alone.

But you might can use parts of it and create your own parser. A more simple one.

Here is the code:
http://code.google.com/p/h2database/source/browse/trunk/h2/src/main/org/h2/command/Parser.java

/Andreas

On Fri, May 6, 2011 at 1:07 PM, IanP <[email protected]> wrote:
> I need to parse out the table names and column names from SQL
> statements that are entered by my users, as I need to check that the
> SQL conforms to certain conventions.
>
> One specific use case is in some circumstances they must select a
> column with an alias of ID and they must select a column with an alias
> of VALUE. So I expect:
>
> SELECT somecol AS ID, someothercol AS VALUE FROM atable WHERE
> something = somethingelse
>
> or alternatively
>
> SELECT ID, VALUE FROM atable WHERE something = somethingelse
>
> if atable already has ID and VALUE columns.
>
> I can do it with regular expressions. I thought it might be more
> interesting(!) to do it with the H2 parser. That should also have a
> nice side-effect of proving that the entire statement is sytactically
> correct too, which would be better than finding out at runtime :-)
>
> Is it possible and easy to do that with the H2 parser without having a
> database connection? If so, can anyone give me any hints or tips about
> how to proceed? Or am I barking up the wrong tree and should stick
> with Regex?
>
> Cheers,
> Ian.
>
> --
> You received this message because you are subscribed to the Google Groups "H2 
> Database" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/h2-database?hl=en.
>
>



-- 
Andreas Henningsson

"Vanligt sunt förnuft är inte särkilt vanligt." -- Voltaire

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to