Results 1 to 19 of 19
Thread: sub query extraction
- 02-08-2012, 08:59 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
sub query extraction
Do we have any inbuilt code in java for extracting sub query from the nested queries?
Can anyone suggest me any open source projects on this or get me the code for extracting the query from nested query
For example if u have the input ass nested query the inner query needs to be obtained and then the outer query.. once i execute the inner query i need to get a result set and the outer query needs to use this result set for further processing.
- 02-09-2012, 09:44 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: sub query extraction
Um....why?
Are you writing a database by any chance?
If not then...why?
- 02-09-2012, 12:44 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
Re: sub query extraction
nope.
actually i am implementing an IEEE paper and i have a greesy heuristics algorithm which does this process of sub query extraction. SO i wanted to know is there any method to perform. Because of that the performance of the system gets improved.
- 02-09-2012, 12:58 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: sub query extraction
When most people see "query" in a Java context it usually means SQL.
You'll probably have to provide more information of what you're dealing with so someone here might be able to pick it up.
- 02-09-2012, 02:21 PM #5
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
Re: sub query extraction
actually in my program , i will have a prepared statement containing the query
select temp from weather where date in (select date from weather where place='chennai' AND latitude='20' AND longitude='30')
What is wanted to do is this split this nested query into sub query as below
select date from weather where place='chennai' AND latitude='20' AND longtitude='30'
select temp from weather where date in ( solution of above query will be passed over here)
Can anyone suggest me how to code this. ?
- 02-09-2012, 02:24 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: sub query extraction
I still don't see why bother, as it gives you no info about how the underlying database is working.
There's unlikely to be an API for it, so you'd have to manually break it up.
ALso, since it's a PreparedStatement, the query will be:
And getting at the bind variables might be entertaining.Java Code:select temp from weather where date in ( select date from weather where place=? AND latitude=? AND longtitude=?)
- 02-09-2012, 05:52 PM #7
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
Re: sub query extraction
yeah thats correct . The data for the place, latitude, longtitude will be entered by the user in a jsp. These values will be passed to a servlet and it will be updated in the prepared statement.
So can you explain me how can i proceed now.?
And you mentioned me about the API . Can you tell me about the available API ?
- 02-09-2012, 06:06 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: sub query extraction
I said there isn't likely to be one.
You'll have to figure out how to break up the query string yourself.
In fact, since it's in your code why not simply store the parts of the query somewhere and look at those?
Or is the user entering the full SQL?
- 02-09-2012, 06:12 PM #9
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
Re: sub query extraction
Nope i am forming the SQL Query. In my project i need to show the first SQL Multiple Query and then i need to apply the algorithm to form the sub Query . And the3rd module deals with executing the sub query on the data aggregators.
And i have an idea of
1.converting the prepared Statement to a String using the toString method.
2. Now splitting the query by using String split method at the select .
3. And then executing the query
Will these steps work out?
- 02-10-2012, 09:48 AM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: sub query extraction
I realise this is a project, but I'm still struggling to see the goal (and "splitting the query" is not a goal, IMO).
Anyway, yes, you could do that. As to whether they "work" that is all dependent on the actual goal of this thing.
- 02-10-2012, 02:59 PM #11
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
Re: sub query extraction
The main aim is to process the continuous aggregation queries efficiently.
If possible you can have a look at the IEEE paper with the title "Query planning for continous aggregation of queries over a network of Data aggregators."
- 02-10-2012, 03:11 PM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: sub query extraction
Ah.
So it's querying scattered data, so you break down the request into the sub clauses, each of which can hit a different data source (aggregator in the case of the paper).
Now I have that in my head...a SQL parser might help?
ZQL is a possibility, if maybe a bit unsupported.
There will be parsers in most JDBC drivers, though they may simply do a quick check of the query rather than breaking it down into components like ZQL. The one in Apache Derby might be worth a look.
- 02-10-2012, 04:24 PM #13
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
Re: sub query extraction
Can apache derby breakdown my query .
but i dont have any idea about that . Can you suggest me some examples?
- 02-10-2012, 04:26 PM #14
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
Re: sub query extraction
Is derby a complete database like MySql?
- 02-10-2012, 04:36 PM #15
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: sub query extraction
Yes, Derby is a complete databse, written in Java and it's open source.
Somewhere in there will be a SQL parser.
It's possible that might break down a query into it's constituent clauses in a way you could use, but it might be too tied into how Derby views things for you to be able to hack it.
(I actually meant "most databases" above, and not "most drivers", which wouldn't make too much sense).
Also, thinking about it, Hibernate has its own SQL, so there is likely to be a parser in there as well. Again, though, it is likely to be very particular to how Hibernate views the world.
Albeit a bit old I'd still give ZQL a look, just in case.
- 02-10-2012, 06:04 PM #16
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
Re: sub query extraction
I am totally confused now. Can you tell me the best one for parsing the query.
How about the way i told u by placing PreparedStatement in a String.
- 02-13-2012, 11:21 AM #17
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: sub query extraction
The problem there is that I don't know what restrictions you have on your queries.
And, as I say, the bind variables are not so easy to get at.
- 02-13-2012, 02:34 PM #18
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
Re: sub query extraction
Hey i used a zql parser to split according to my requirements. <br/>
If anyone wants to do any operation on sql queries plz suggest them with GNU projects like ZQL.<br/>
parser can help you in some way but a few coding needs to be done by us to get the exact expected result.<br/>
Anyways Thanks for helping me out to get to a solution.
- 02-13-2012, 03:00 PM #19
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
green channel extraction
By sarah49 in forum Java 2DReplies: 1Last Post: 01-27-2012, 11:14 AM -
Data extraction, pleas help!!
By bob nash in forum New To JavaReplies: 1Last Post: 05-04-2011, 08:09 AM -
Data Extraction using JAVA
By yap_1991 in forum Advanced JavaReplies: 1Last Post: 06-01-2010, 08:02 AM -
JAVA Video Extraction
By KSadeck in forum Advanced JavaReplies: 3Last Post: 01-08-2009, 07:43 AM -
web extraction
By murali in forum NetworkingReplies: 3Last Post: 12-13-2008, 07:10 AM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks