A query database can be synched with an open database viewer. This is a powerful construct as you can write actions which employ query database functionality where the results are posted to an instance of the database open in the UI.
The synch capability is enabled by specifying a desire to grab an already open database via an Open Query Database statement. When a database is grabbed it is disabled as long as the grab persists. When the query database is closed, all modifications appear in the open databases's viewer.
There are special sematics when closing a query database which was opened with a grab. See the Close/Save Query Database statement for more information.
A query database which is grabbing an open database does not have a copy of the database data. It is always using the data store in the open database. As such, the database cannot save or discard changes by the Close/Save Query Database statement. The statement can only be used to close the query database which will release the grab. Note that all query databases are automatically closed when action execution terminates.
The non query Database Statements can be used to perform typical database functionality while the grab is in place. The only exception is that the Close Database statement will not work while the database is grabbed.
The Open Query Database statement sets two interesting named variables when a database is grabbed:
If an action is directly run from a Database Viewer, the action will automatically grab the database and open the query database. The opened query database has an identifying prefix of UI, is keyless and is opened as grabbing. Running an action this way eliminates the need of locating and opening the database in the action. Additionally two other named varables will be created: