I need to give users the ability to build a simple SQL query against our database. Our application is written in Delphi.
I am assuming only moderate levels of knowledge by the user, but they need the ability to build a simple select statement to be able to query against a couple of tables. If I can make this easy for them, that would be most wondrous.
Does anyone know of a tool or a set of components that I can use to help the users build SQL SELECT statements...
I've used the DevExpress ExpressFilter control to allow users to specify SQL where constraints before.
I've come across FastQueryBuilder http://fast-report.com/en/products/visual-query-builder.html
and
OpenQueryBuilder http://fast-report.com/en/products/free-query-builder.html
(apparently differing versions of the same tool) at Fast-Report.
It looks like the right idea. Anyone have any experience with it?
I've used SimpleQuery for years and am quite happy with it. (http://devtools.korzh.com/eq/vcl/) It's not completely intuitive, but once you get the hang of it, you can present fields to the user from your database(s) and they can combine any series of them with ANDs and ORs to make very complex queries. You get a separate SQL window to save the resulting code. I make The resulting dataset available for printout with PrintDat! or to save as CSV data from the Woll2Woll Infopower grid that I use for display. I occasionally allow for XLS export too with XLSReadWrite. It's all quite automatic at this point. Just take the SimpleQuery example and mold that to your particular needs. You should be able to have something very usable in a day. There is a trial and an example free query builder standalone program that will give you an idea of the final look.
TMS Query Studio? Good value at 75 Euro..
Try EMS Advanced Query Builder.
is a powerful component suite for
Borland® Delphi® and C++ Builder®
intended for visual building SQL
statements for the SELECT, INSERT,
UPDATE and DELETE clauses. It allows
you to build new queries visually
and/or graphically represent the
existing queries in your own
applications. The suite includes
components for working with standard
SQL, MS SQL, InterBase/Firebird,
MySQL, PostgreSQL and many more
dialects. Advanced Query Builder
enables users to make up large and
complicated SQL queries with unions
and subqueries for different servers
without any knowledge of the SQL
syntax.
(source: sqlmanager.net)
(source: sqlmanager.net)
I think the most powerful one is ActiveQueryBuilder, which now included with Delphi IDE (Since 2007 I think)
(source: activequerybuilder.com)
I've written a couple of similar things in Delphi. It's easy enough to allow the user to pick table and column names by querying the metadata and using lists and tree views for display. The difficulty comes when trying to implement things like joins. I've never come up with a good interface for this, and in my experience neither have many of the major data tools players.
You may want to try this free builder:
GSC Visual Query Builder v.0.7
Visual Query Builder v.1.0
and some other in Torry:
http://www.torry.net/pages.php?id=546
Related
I am writing an OpenSQL query, including joins and sub-selects, and I am unsure whether it works. To find out, I'd like to run it somewhere, look at the results, then change it, it an iterative way.
Traditional tools like transactions SE16 or SQVI don't help, because they have too little functionality (only one table, only joins but no sub-selects, etc.). Other threads with similar questions, like this one remained unanswered.
Of course, I could write a report or a unit test, paste my code there, and run it, but this makes the iterative cycle so slow because I need to change input and output data formats all the time. Optimal solution would be something like the SQL Console in SAP HANA Studio, but for OpenSQL instead of native SQL.
(on behalf of #Florian) Use the SQL console in Eclipse. it allows Open SQL SELECT, except FOR ALL ENTRIES and variables.
(on behalf of #JozsefSzikszai) software "OpenSQL Editor for SAP", by STA Consulting Kft. There is a 30 days trial period, so might be a short term solution only (unless your company buys it)
Use the tool ZTOAD, created by Sébastien Hermann : http://quelquepart.biz/article7/ztoad-requeteur-open-sql.
You may indirectly test the Open SQL statements by creating test classes (ABAP Unit), in which you use the class CL_OSQL_TEST_ENVIRONMENT (ABAP >= 7.52), which is used to mock the database, so you may provide false data, enter the expected result, execute the open SQL in test mode, and verify that actual result = expected result. It supports all Open SQL features.
All the above solutions allow testing Open SQL directly. Another solution is to use native SQL editors, and to write the Open SQL statements in the Strict mode (ABAP >= 7.40) so that they are closer to the native SQL syntax (especially the comma is to be used to separate the column names; but the alias separator has to be manually changed from ~ to .). There are two native SQL editors: one is a tool in ST04 or ST04N, one is the standard program RSDU_EXEC_SQL. Both display the result of SELECT statements in an ALV grid.
Good morning,
you could take a look into queries (SQ01/SQ02) instead of QuickViews in SQVI. In Queries you have a chance to enhance your Joins with coding and you are still able to test your "code". For incremental changes this might be your easiest way to go.
Regards
I'm getting started with SQL. So far, most of my experience is either with simple queries using C# (then performing operations on the data in C#), or designing [relatively] more complex queries with MS Access' design view.
I was recently assigned a task to review a relatively large query (hundreds of rows for a single Select), and there are minimal comments in the code. Also, I'm not familiar with the database being queried. Even though the syntax seems relatively simple, there are so many joins on top of joins that it's hard to wrap my head around.
Ideally, I'd like to have some graphical representation, similar to MS Access' design view. Note that my current position uses SSMS. I'm aware there are tools that can create SQL code from a UML diagram. I'm also aware that there are tools that can create a ER diagram from SQL code (see this question), which is closer to what I'm looking for. Are these ER tools my only option? As far as I can tell, the ER tools only show db relationships, and not specific queries with special types of joins or functions.
Thank you.
If you're using SQL Management Studio (I use 2008) you can just right click on the diagrams drop down in the explorer and click Create New Diagram. I'm not sure if this is what you are looking for but this is how I make all of my ER diagrams for my database.
No, It is impossible to do this by using standart tools like SQL Management Studio or others.
Maybe there exist some specific tools for this.
It is difficult and interesting task to generate joins diagram from SQL query (It is simple for "joins" but how does "union" and "where" clauses should be explained on diagram?)
And I think it doesnt simplify you task.
I would like to build arbitrary queries to a database, by allowing the user to build queries "on the fly". For every object/table, being able to select its attributes, and then "building" the query (that would translate into a SQL statement) and finally launching it, all through a web interface.
The ticketing system "rt" does that, for example, and another example would be the http://gatherer.wizards.com/Pages/Advanced.aspx webpage.
I'm currently programming in rails but any existing solution that implements this (or something similar) would be welcome.
Just be careful when creating dynamically generated queries like this that will need to be executed via sp_executesql (example: ms sql server), etc..... make sure you cover all of your bases to ensure that your application isnt vulnerable to SQL injection attacks as this type of development will essentially get one in a lot of trouble if its done incorrectly.. I would recommend storing all queries in a table and only reading queries from this table to help isolate the queries that are being ran in your application. Just identify them with a label, and allow the EU to choose the label from a dropdown list control on the frontend.
Good luck and I'm not sure of any software that will help assist
Not quite sure what your use case is here but i would say check out the
Doctrine ORM ( Object Relational Mapper )
**Edit
After reading more and looking at the example. I would only suggest Doctrine for a large website.
Then use Doctrines DQL syntax with some javascript/jquery magic for the forms.
Note that the queries you're referencing aren't arbitrary: they're on a very specific problem domain, on a specific set of sql tables.
That said, if I were you I'd look into how people are building sql queries with javascript. Something like these:
http://code.google.com/p/django-querybuilder/
http://css.dzone.com/articles/sqlike-sql-querying-engine?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+zones%2Fria+(RIA+Zone)
http://thechangelog.com/post/4914956307/rel-arel-ported-to-node-js-with-some-changes
That'll at least get you a good idea of the underlying data structures.
My intention is to write a graphical query language where users can drag and drop criteria into a GUI query designer, then the designer will generate appropriate SQL query code and return the appropriate result set. Do you know where I can learn more about SQL code generation or if similar tools like this exist?
You may want to look at Microsoft Access's query designer to see how it works; it's relatively simple to use and you can compare how changes in the graphical representation affect the SQL statement and vice-versa. It should give you a pretty good view of how joins are translated into SQL.
(I cringe to suggest Microsoft Access for anything, but in this case, it might be useful to you).
I'm looking for a tool, which would help creating complex SQL queries. Sometimes it's difficult to even verify, whether the results of a query are correct. It's especially easy to get queries joining several tables to return too little or too much data.
The tool should enable at least creation of test tables, some kind of visualization how the queries gather their data and hopefully give better parsing of error cases than for example Oracle does.
Are there tools like this or do I have to stick with creating test tables manually, filling them with test data and commiting all kinds of queries with SQuirrel SQL?
When you have a very complex query it is usually easiest to validate by breaking it up into multiple queries that populate temp tables. These intermediary results can be individually verified and then you bring them together to produce the final result set. Depending on performance needs you can stick with the temp table approach or you can then rewrite to a single statement. Typically when I have a huge query it is for background processing so I stick with the temp table approach.
What RDBMS are you using? All of the major ones have some type of console available (e.g.-SSMS in SQL Server, Toad in Oracle, MySQL Query Browser/Administrator for MySQL, etc.), and they all have Query Execution Plans where you can see how the query will actually run. So, the answer to your question is that it's entirely dependent on what RDBMS you're using, but the safe bet answer is: Yes.
I recommend trying SQL Server 2008 Management Studio Express (SSMSE) if you are working with SQL Server. I have used it at work and I believe it does everything you are looking for.
You can get it and SQL Server (express editions) here.
Certainly not a free, open-source solution, but I believe Quest Software's TOAD will fit your requirements. Quest seems to offer alot of tools in that space...they have tools for modeling and analysis, however I've never used the modeler or analyzer.
I personally have experience with the commercial version of TOAD for Oracle. It's GUI is overwhelming at first, but after you mentally filter out all of the extra buttons that you'll never use, it's manageable.