Generates a SQL statement from an operator and arguments.
sql
sql-operation op &rest args => sql-result
op⇩ |
An operator. |
args⇩ |
A set of arguments for op. |
sql-result |
A SQL expression. |
The function sql-operation
takes an operator op and its arguments args, and returns a SQL expression.
(sql-operation op args)
is shorthand for:
(apply (sql-operator op) args)
.
The following pseudo operators can be used for op:
A call for the form: (sql-operation 'sql-function name &rest function-args) allows an arbitrary function name to be passed. In this case, name is put in the SQL expression using princ, and function-args are given as arguments. | |
Calls for the form: (sql-operation 'sql-operator value-inop left &rest rights) (sql-operation 'sql-boolean-operator bool-inop left &rest rights) generate SQL that calls an infix operator with left on the left and rights on the right separated by spaces.
Use |
The pseudo operator sql-operator
should not be confused with the Common SQL function sql-operator.
The following code, uses sql-operation
to produce a SQL expression.
(sql-operation 'select (sql-expression :table 'foo :attribute 'bar) (sql-expression :attribute 'baz) :from (list (sql-expression :table 'foo) (sql-expression :table 'quux)) :where (sql-operation 'or (sql-operation '> (sql-expression :attribute 'baz) 3) (sql-operation 'like (sql-expression :table 'foo :attribute 'bar) "SU%")))
The following SQL expression is produced.
#<SQL-QUERY: "(SELECT FOO.BAR,BAZ FROM FOO,QUUX WHERE ((BAZ > 3) OR (FOO.BAR LIKE 'SU%')))">
The following code illustrates use of the pseudo operator sql-function
:
(sql-operation 'sql-function "TO_DATE" "03/06/99" "mm/DD/RR")
The following SQL expression is produced.
#<SQL-VALUE-EXP "TO_DATE('03/06/99','mm/DD/RR')">
LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:56