PRINT-QUERY — Prints a tabular report of query results.
Function
query-expressionAn sql expression that represents an SQL query which is expected to return a (possibly empty) result set.
databaseA 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.
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.
(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
=>