Next Prev Up Top Contents Index

sql-operation

Function
Summary

Generates an SQL statement from an operator and arguments.

Package

sql

Signature

sql-operation op &rest args => sql-result

sql-operation function func &rest func-args => sql-result

Arguments

op

An operator.

args

A set of arguments for op.

func

An arbitrary function.

func-args

A set of arguments for func .

Values

sql-result

An SQL expression.

Description

The function sql-operation takes an operator and its arguments, and returns an SQL expression.

(sql-operator op args )

is shorthand for

(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.

Example

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')">
See also

sql
sql-expression
sql-operator


LispWorks Reference Manual - 25 Jul 2003

Next Prev Up Top Contents Index