db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From venu <VENUM...@GMAIL.COM>
Subject Re: Using ASTParser and TreeWalker for parsing SQL query
Date Mon, 01 Jul 2013 04:09:16 GMT
Hi Rick,
Thanks for spending your valuable time on this issue. 
Sorry if I ask the same question again.

Could you please help me on this ?
select colName from tableName where id=100 having COUNT(*) > 1
When I go through the nodes, I can see the where clause and having clause
both have defined in a same way (node tree structure). 

Both doesn't have parent node. Both are using BinaryRelationalOperatorNode
as parent node if, both have the condition with some operator (like = in
where clause and > in having clause).

But, for differentiate these two we don't have any parent node.
For example if we take a look at from or groupby or orderby they have root
nodes like fromlist, groupbylist and orderbylist.

for where clause and having clause both doesn't have parent node.
		operator: =
		methodName: equals
		dataTypeServices: null
			columnName: ID
			tableNumber: -1
			columnNumber: 0
			replacesAggregate: false
			replacesWindowFunctionCall: false
			tableName: null
			nestingLevel: -1
			sourceLevel: -1
			dataTypeServices: null
			value: 100
			dataTypeServices: INTEGER NOT NULL
		operator: >
		methodName: greaterThan
		dataTypeServices: null
			aggregateName: COUNT(*)
			distinct: false
			operator: null
			methodName: null
			dataTypeServices: null
			value: 1
			dataTypeServices: INTEGER NOT NULL

If I provide any conditional operator like AND or OR to where clause or
having clause, then the structure is different for both of these two.

My problem is, I want to take having clause data and where clause data from
the query.

So, not able to get the data properly due to the structure is changing for
these two items every time.

Is there any way to differentiate these two elements ?
or can we add any parent node for these two like others?
If not possible could you please give some advice on 'where I need to change
or which way I need to move' for solving my issue ?

Thanks in advance,

View this message in context: http://apache-database.10148.n7.nabble.com/Using-ASTParser-and-TreeWalker-for-parsing-SQL-query-tp131219p132167.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.

View raw message