LispWorks User Guide and Reference Manual > 19 Common SQL > 19.5 Symbolic SQL syntax


19.5.2 Programmatic interface

In some cases it is necessary to build SQL-expressions dynamically under program control.

The function sql-operation returns the SQL expression for an operator applied to its arguments. It also supports building SQL expressions which contain arbitrary SQL functions using the pseudo operators sql-function , sql-operator and sql-boolean-operator . For examples see sql-operation.

The function sql-expression makes an SQL expression from the given keywords. This is equivalent to the first and third uses of the [] syntax as discussed in The "[...]" Syntax.

The function sql-operator returns the Lisp symbol for an SQL operator.

The function sql makes SQL out of the arguments supplied. Each argument to sql is turned into SQL and then the args are concatenated with a single space between each pair. A Lisp string maps to the same characters enclosed between single quotes (this corresponds to an SQL string constant). nil maps to "NULL" , that is, an SQL null value. Symbols and numbers map to strings. A list maps to a parenthesised, comma-separated expression. A vector maps to a comma-separated expression, which allows the easy generation of SQL lists that require no parentheses such as table lists in select statements.

The rules for the conversion are fully specified in sql. Examples

LispWorks User Guide and Reference Manual - 22 Dec 2009