An operator.
A set of arguments for op.
An arbitrary function.
A set of arguments for func .
The function
sql-operation
takes an operator and its arguments, and returns an SQL expression.
(sql-operator
op
args
)
(apply (sql-operator
op
)
args
)
.
The pseudo operator
function
allows an arbitrary function
func
to be passed. In this case,
func
is put in the SQL expression using
princ
, and
func-args
are given as arguments.
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
function
:
(sql-operation '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')">