tags:

views:

147

answers:

6

what would be the best way to create a Query builder in delphi?

I have devexpress quantum grid, so I can display data easily.

+3  A: 
Lieven
Hi there! yes indeed Quantum grid has a powerful filtering system:) where did you find the SQLbuilder object?
Plastkort
I doesn't exists yet (to my knowledge). It is something we wish to implement ourselves... someday <g>
Lieven
@Lieven: What this needs is a way to ALSO bind the data to some sort of object/object set. If the .column method also takes a parameter of where to bind the data, then this becomes much more useful than a simple code generator.
skamradt
Good idea but coming to think of it: doesn't LINQ do all this already out of the box (binding, generating, ...)
Lieven
ah, I see, you suggesting to create something of a TSQLBuilder class object.. is really a good idea :). I might think of something like this. the hard part would probably to put it all together to a Tstringlist, and or reverse it back to this format if you wanted to modify it :)
Plastkort
A: 

It really depends on how complicated and intuitive you want the query builder to be. I wrote a cheap and cheerful SQL Query Form into an app in Delphi 5, using a TMemo component only allowing the Select commands to be run. There are various sql queries you can run to gather information from SQL on schema so you can get the tables and fields in a database and populate a treeview component or something like that.

Matt
A: 

What you mean by "Query Builder"? do you need a visual component for the end-user to build SQL queries or some kind of programmatic solution? And what means "the best way"? Can you list the considered ways to cope with this task?

ssmagin
for the time being, SQL queries written in a TMemo would be OK, as my budget is low I cannot afford any fancy visual builder:).. maybe that will change in the future, I really hope so
Plastkort
A: 

Why write your own when there already is a solution ready to be compiled into your application? The folks at fast-reports have a nice query builder that includes complete source. There also is an open source version, although you would have to update it yourself to support Unicode.

skamradt
at this moment, my budget is tiny, so if I can write something myself, that would be the best for the time being
Plastkort
A: 

At least as of a few years ago, best query building component for Delphi was "Simple Query", an inexpensive component from a Russian toolmaker. Great component, features are much deeper and better thought out than they might at first appear. I used it with good success to integrate with data in QuantumGrid. (Since Simple Query merely generates an SQL string there isn't really much to integrate that way. But I did also tailor the visual appearance so it looked consistent with the QG.) http://devtools.korzh.com/query-builder-delphi/

Note that the interface for Simple Query (and their "Easy Query" .NET component) is geared towards making it simple for users to generate valid searches without having any concept of tables, joins, or SQL. Takes a bit of foresight by developer to configure interface perfectly that way, but it's a nice feature. Also can be used as "full strength" solution for database experts.

Also, I assume you're aware that QG has its own integrated visual query system. I think my main problem with that was that it was mostly geared towards filtering the existing dataset, but in any case Simple Query was far more flexible.

Another thing, under the covers Simple Query has a number of objects that are used to generate the final SQL string, analogous to the code you posted and are asking about. Main purpose for this was just as intermediate stage between visual description and final output as SQL.

Herbert Sitz
+1  A: 

I have used Active Query Builder (http://www.activequerybuilder.com/product_vcl.html) as the UI for users to build queries. It includes an option to match the look and feel of the Dev Express grid, if you buy the source code.

Sam M