# Close/Save Query Database

As a rule, query databases are automatically closed when either the Batch Processor terminates or if not batch processing, when action processing terminates. Modifications are automatically saved.

If for any reason you wish to close a query database manually, you can do so via this statement. The statement allows you to close discarding changes, close saving changes or to save changes and keep the database open.

Note that if the query database was opened by grabbing a database already open in the UI, special semantics are applied as follows:

Close discarding changes
  Closes the query database and releases the grab on the UI database. However it will not discard the changes! Changes can be discarded by subsequently closing the UI database via a Close Database statement with the Discard Changes option set. Alternately when the database is closed in the UI, changes can be discarded.
Close Saving changes
  Closes the query database and releases the grab on the UI database. However it will not save the changes! Changes can be discarded by subsequently closing the UI database via a Close Database or Save Database statement.
Save changes (keep open)
  The database remains open and while nothing is saved the open database will refresh its display. Use a Save Database statement to save the changes.

Note that when not batch processing, grabbed databases can be filtered when closed by this statement by setting the Filter on grabbed close option. Two named variables control how the database is manipulated when closed:

Query Database Grabbed Close Format
  Three codes are currently supported:
  A
    Autosize the columns.
  X
    Removes any active filter when the grab is released. ie. the entire database will be displayed. No rows will be selected.
  S
    Sort the database as it was last sorted.
Query Database Grabbed Close Filter
  This named variable is only examined if Query Database Grabbed Close Format did not contain an X indicator. The named variable is treated as a list of keys. Every item in the list must either be a valid symbolic key or an absolute row index (#row number). The list item delimiter must be the default list delimiter (\~). Only those rows specified in the list (if any) will be displayed.

Click here for information on identifying an open database.

The path may contain any of the escape sequences described in Escape Sequences.