sql-operation op &rest args => sql-result
sql-operation sql-function name &rest args => sql-result
sql-operation sql-operator inop1 left &rest rights => sql-result
sql-operation sql-boolean-operator inop2 left &rest rights => sql-result
An operator.
A set of arguments for op.
An arbitrary function.
A set of arguments for name .
An infix operator with non-boolean result.
An infix operator that returns a boolean.
Argument to be placed on the left of an infix operator.
Arguments to be placed on the right of an infix operator.
The function
sql-operation
takes an operator and its arguments, and returns an SQL expression.
(sql-operation
op
args
)
(apply (sql-operator
op
)
args
)
.
The pseudo operator
sql-function
allows an arbitrary function
name
to be passed. In this case,
name
is put in the SQL expression using
princ
, and
args
are given as arguments.
The pseudo operators
sql-boolean-operator
and
sql-operator
generate SQL that calls an infix operator with
left
on the left and
rights
on the right separated by spaces. Use
sql-boolean-operator
for SQL infix operators that return a boolean and use
sql-operator
for any other SQL infix operator.
Note: the pseudo operator
sql-operator
should not be confused with the Common SQL function sql-operator.
The following code, uses
sql-operation
to produce an 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')">