
In some cases it is necessary to build SQL-expressions dynamically under program control. The following functions are provided to this end:
 sql-operation  op &rest  args Returns the SQL for an operator applied to its arguments. That is, this is equivalent to the second use of the [] syntax above where SQL strings represent symbolic expressions. This function is shorthand for
 (apply (sql-operator  op )  args ) sql-expression &key  string  table  alias  attribute  type 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. Valid combinations are:
table-alias , attribute , and type
 sql-operator  symbol Returns the symbol for an SQL operator (that is, sql-  symbol ).
 sql &rest  args Makes SQL out of  args . Each argument to sql is turned into SQL and then the  args are concatenated with a single space between each pair. The rules for translation into SQL are as follows (based on the type of each individual argument x ):
 string --> (format nil "'~A'" x) That is, the characters of x between single quotes (this corresponds to an SQL string constant);
 (sql null) --> "NULL"symbol --> (symbol-name x)
number --> (princ-to-string x)
list --> (format nil "(~{~A~^,~})" (mapcar #'sql x)) That is, the elements of x in SQL, between parentheses separated by commas.
 vector --> (format nil "~{~A~^,~}" (map 'list #'sql x)) That is, the elements of x in SQL, comma-separated, without parentheses. This is to allow the easy generation of SQL lists that require no parentheses such as table lists in select statements.
sql-expression --> x
otherwise --> (error)