Name

Function SQL-OPERATION — Constructs an SQL expression from a supplied operator and arguments.

Function

Syntax

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

Arguments and Values

operation

A symbol denoting an SQL operator.

func

A string denoting an SQL function.

args

A set of arguments for the specified SQL operator or function.

result

A object of type sql-expression.

Description

Returns an SQL expression constructed from the supplied SQL operator or function operation and its arguments args. If operation is passed the symbol 'function then the first value in args is taken to be a valid SQL function and the remaining values in args its arguments.

Examples

(sql-operation 'select 
          (sql-expression :table 'foo :attribute 'bar)
          (sql-operation 'sum  (sql-expression :table 'foo :attribute 'baz))
          :from 
          (sql-expression :table 'foo) 
          :where 
          (sql-operation '> (sql-expression :attribute 'bar) 12)
          :order-by (sql-operation 'sum (sql-expression :attribute 'baz)))
=> #<SQL-QUERY SELECT FOO.BAR,SUM(FOO.BAZ) FROM FOO WHERE (BAR > 12) ORDER BY SUM(BAZ)>

(sql-operation 'function "strpos" "CLSQL" "SQL")
=> #<CLSQL-SYS:SQL-FUNCTION-EXP STRPOS('CLSQL','SQL')>
      

Side Effects

None.

Affected by

None.

Exceptional Situations

An error of type sql-user-error is signalled if operation is not a symbol representing a supported SQL operator.

Notes

None.