Is it possible to show the progress of an SQL query in Delphi? For example I have a long complicated query in Firebird and I want to show the user how much percentage of the query has already been completed by the system. Are there any class or component capable of doing this?
I don't think that you'd be able to show anything beyond the progress of the data retrieval part of the process. When you send your SQL to Firebird, you won't hear back until the data is ready to be received by your program (depending on what method/components you are using.)
AFAIK, there is no ability to measure the query execution time and to show the progress indicator. DBMS does not provide such information.
But you can show "wait" dialog with ability to cancel the query. We do that with AnyDAC. Set ResourceOptions.CmdExecMode to amCancelDialog and drop the TADGUIxFormsAsyncExecuteDialog component. Then user will have an ability to cancel the query.
It strictly depends on your database. Some publish those informations (i.e. Oracle puts them in the v$session_longops view), others don't. Usually you have to thread your queries, unless the database offer some kind of callbacks during the process - again that's a database specific feature. Some allow to terminate a long running query before the end, others don't. Check your database documentation. And if a feature is available, the library you use to access the database has to surface it, otherwise you may need to call the DB client library directly.