PRINT-QUERY
Prev | Functional Data Manipulation Language (FDML) | Next

## Name

PRINT-QUERY — Prints a tabular report of query results.Function

## Syntax

          print-query query-expression &key titles formats sizes stream database =>

## Arguments and Values

`query-expression`

  An sql expression that represents an SQL query which is expected to return a (possibly empty) result set.

`database`

  A database object. This will default to the value of *default-database*.

`titles`

  A list of strings or `NIL` which is the default value.

`formats`

  A list of strings, `NIL` or `T` which is the default value.

`sizes`

  A list of numbers, `NIL` or `T` which is the default value.

`stream`

  An output stream or `T` which is the default value.

## Description

Prints a tabular report of the results returned by the SQL query `query-expression`, which may be a symbolic SQL expression or a string, in `database` which defaults to *default-database*. The report is printed onto `stream` which has a default value of `T` which means that *standard-output* is used. The `title` argument, which defaults to `NIL`, allows the specification of a list of strings to use as column titles in the tabular output. `sizes` accepts a list of column sizes, one for each column selected by `query-expression`, to use in formatting the tabular report. The default value of `T` means that minimum sizes are computed. `formats` is a list of format strings to be used for printing each column selected by `query-expression`. The default value of `formats` is `T` meaning that ~A is used to format all columns or ~VA if column sizes are used.

## Examples

    (print-query [select [emplid] [first-name] [last-name] [email]
                         :from [employee]
                         :where [< [emplid] 5]]
                  :titles '("ID" "FORENAME" "SURNAME" "EMAIL"))
    ID FORENAME SURNAME  EMAIL
    1  Vladimir Lenin    lenin@soviet.org
    2  Josef    Stalin   stalin@soviet.org
    3  Leon     Trotsky  trotsky@soviet.org
    4  Nikita   Kruschev kruschev@soviet.org
    =>

    (print-query "select emplid,first_name,last_name,email from employee where emplid >= 5"
                 :titles '("ID" "FORENAME" "SURNAME" "EMAIL"))
    ID FORENAME   SURNAME   EMAIL
    5  Leonid     Brezhnev  brezhnev@soviet.org
    6  Yuri       Andropov  andropov@soviet.org
    7  Konstantin Chernenko chernenko@soviet.org
    8  Mikhail    Gorbachev gorbachev@soviet.org
    9  Boris      Yeltsin   yeltsin@soviet.org
    10 Vladimir   Putin     putin@soviet.org
    =>

## Side Effects

None.

## Affected by

None.

## Exceptional Situations

If the execution of the SQL query leads to any errors, an error of type sql-database-error is signalled.

## See Also

`query`
`do-query`
`map-query`
`loop`
`select`

## Notes

None.

Prev | Up | Next
QUERY | Home | SELECT