Hello everybody! This is my first message to this list so I greed you all! (I apologise in advance for my bad english).

I  am using HSQL in a VB.NET solution. At a certain point I want to parse an SQL SELECT query and draw a graph that visualizes the query in a very specific way.
So I create a parser object (named p), and a select object (named sSelect) that the parser create when it calls the parseselect function.
I know how to extract all the column and table names from the select object , but I cannot learn how to "read" the WHERE part of the SELECT statement.
I have checked the code of the parser object, and I can understand that the WHERE part is stored in the eCondition _expression_.
So my question is the following: How can I read the WHERE part of the SELECT statement and create a table for example that contains every condition that exists in the WHERE part?
Now that I think about it a little more, how can I "read" all the expressions that exists in the eCondition _expression_?
I tried using the SELECT.RESOLVE method and the PARSER.PARSEEXPRESSION method but I couldn't understand exactly how they work.


            Dim c As New SharpHSQL.Tokenizer(stSQL) 'stSQL is the SELECT statement that I want to parse
            Dim p As New SharpHSQL.Parser(d, c, channel)
            Dim sToken As String
            Dim sSelect As New SharpHSQL.Select

            sToken = c.getstring 'This is used just to remove the SELECT string

            sSelect = p.parseSelectAltered 'parseSelectAltered is a copy of the parseSelect method that is declared as PUBLIC

            Dim myLog As New Log("log.txt")

            'PRINT TABLE AND COLUMN NAMES THAT EXISTS IN THE QUERY

            Dim ex As SharpHSQL._expression_
            Dim myEnumerator As System.Collections.IEnumerator = sSelect.eColumn.GetEnumerator()

            myLog.Write("---==<{[ COLUMNS ]}>==---")
            myLog.Write("Alias" + ControlChars.Tab + "Tbl" + ControlChars.Tab + "Column" + ControlChars.Tab + "Type")
            While myEnumerator.MoveNext()
                ex = myEnumerator.Current
                myLog.Write(ex.getAlias + ControlChars.Tab + ex.getTableName + ControlChars.Tab + ex.getColumnName + ControlChars.Tab + Str(ex.getType))
            End While
            myLog.Write("")
            myEnumerator = Nothing
            ex = Nothing

            Dim ta As TableFilter

            myEnumerator = sSelect.tFilter.GetEnumerator
            myLog.Write("---==<{[ TABLES ]}>==---")
            myLog.Write("Alias" + ControlChars.Tab + "Tbl")
            While myEnumerator.MoveNext()
                ta = myEnumerator.Current
                myLog.Write(ta.getName + ControlChars.Tab + ta.getTable.getName)
            End While
            myLog.Write("")

            myEnumerator = Nothing
            ta = Nothing



Reply via email to