Detailed features: GNOME Data Access 5 manual

## Detailed features

This section explains in depth various aspects of the console tool.

## Query buffer

Everytime an SQL command is entered, it is stored in the query buffer associated to the current connection. The query buffer can be edited using an external editor (which can be useful for multi line SQL statements) using the .e command. The query buffer can also be saved to a file and loaded back later using the .qw and .qr commands. To execute the SQL held in the current query buffer, use the .g command.

Query buffers can be saved to the dictionary (along with the connection's meta data) for future usage using the .qs buffer_name command, and loaded back later with the .ql buffer_name. To list all the saved query buffers in the dictionary, use the .qa command. The following example shows an example output of the .qa command where one query buffer has been saved:

    SalesTest> .qa
    Query buffer name | SQL
    ------------------+---------------------------------------------------------------------------------------
    orders_status     | select c.name, o.creation_date ,
                        (select count (product_ref) from order_contents oc where oc.order_id=o.id) as '#items'
                        from customers c
                        	inner join orders o on (o.customer = c.id)
                        order by o.creation_date;

    (1 row)
    SalesTest>

The .g command can also be used to load a query buffer and execute its contents simply by passing the name of the query buffer to use as argument:

    SalesTest> .g orders_status
    name           | creation_date | #items
    ---------------+---------------+-------
    Lew Bonito     | 2003-06-28    |      1
    Lew Bonito     | 2004-02-02    |      2
    Mark Lawrencep | 2004-02-02    |      2
    Mark Lawrencep | 2004-02-02    |      0
    Greg Popoff    | 2004-02-02    |      1
    Ed Lamton      | 2006-02-04    |      0
    Ed Lamton      | 2006-02-05    |      0
    Ed Lamton      | 2006-02-05    |      0
    Ed Lamton      | 2006-03-29    |      0
    (9 rows)
    SalesTest>