0

I have my own data store mechanism for store data. but I want to implement standards data manipulation and query interface for end users,so I thought QT sql is suitable for my case. but I still cannot understand how do I involved my indexes for sql query. let say for example, I have table with column A(int),B(int),C(int),D(int) and column A is indexed.assume I execute query like
select * from Foo where A = 10;

How do I involved my index for search the results?.

1 Answer 1

2

You have written your own storage system and want to manipulate it using an SQL like syntax? I don't think Qt SQL is the right tool for that job. It offers connectivity to various SQL servers and is not meant for parsing SQL statements. Qt expects to "pass through" the queries and then somehow parse the result set and transform it into a Qt friendly representation.

So if you only want to have a Qt friendly representation, I wouldn't see a reason to go the indirection with SQL.

But regarding your problem: In SQL, indexes are usually not stated in the queries, but during the creation of the table schema. But SQL server has a possibility to "hint" indexes, is that what you are looking for?

SELECT column_list FROM table_name WITH (INDEX (index_name) [, ...]);

Sign up to request clarification or add additional context in comments.

5 Comments

i thought i can write sql driver from qt.if i'm able implement the QSqlDriver interface and QSqlResult interface it should work right?.
Technically, that should work indeed. But it still means you have to implement your own SQL subset somewhere, as Qt won't help you with that. Qt expects to "pass through" the queries and then somehow parse the result set and transform it into a Qt friendly representation. I extended my answer accordingly.
do you know any database independent sql module with built in parser which is suitable for my requirement.
I doubt there is one suiting your needs. SQL has tons of different proprietary dialects. You might be able to reuse some XText grammar, maybe you have some luck here: code.google.com/a/eclipselabs.org/p/plsql-editor
Oh, for the record: There is a sample for a parser of a quite small SQL subset using Boost.Spirit. I haven't checked if further (doc says it only the select clause, whatever that means), but if you are lucky, that's enough for your application: boost-spirit.com/repository/applications/show_contents.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.