- Documentation
- Reference manual
- Packages
- Constraint Query Language A high level interface to SQL databases
- library(cql/cql): CQL - Constraint Query Language
- CQL Examples
- CQL Simple INSERT
- CQL Simple INSERT with retrieval of identity of the inserted
- CQL Simple DELETE
- CQL Simple SELECT
- CQL Simple UPDATE
- CQL WHERE with arithmetic comparison
- CQL Simple INNER JOIN
- CQL Arithmetic UPDATE with an INNER JOIN and a WHERE restriction
- CQL: Confirm row does not exist
- CQL: Aggregation - Count
- CQL: Aggregation - Sum
- CQL: Aggregation - Average
- CQL: Maximum Value
- CQL: Minimum Value
- CQL: Aggregation requiring GROUP BY
- CQL: INNER JOIN with an aggregation sub-query where the sub-query is constrained by a shared variable from the main query
- CQL: INNER JOIN in an aggregation sub-query
- CQL: Negation
- CQL: EXISTS
- CQL: Left Outer Join
- CQL: List-based Restrictions
- CQL: Compile time in-list constraint
- CQL: Disjunction resulting in OR in WHERE clause
- CQL: Disjunction resulting in different joins (implemented as a SQL UNION)
- CQL: Disjunction resulting in different SELECT attributes (implemented as separate ODBC queries)
- CQL: ORDER BY
- CQL: DISTINCT
- CQL: SELECT with NOT NULL restriction
- CQL: First N
- CQL: Self JOIN
- CQL: Removing null comparisions
- CQL: Three table JOIN
- CQL: Three table JOIN with NOLOCK locking hint
- CQL: SELECT with LIKE
- CQL: Writing exceptions directly to the database
- CQL: TOP N is Parametric
- CQL: Using compile_time_goal/1
- CQL: ON
- CQL: Expressions In Where Restrictions
- CQL: Explicitly avoid the "No WHERE restriction" message
- CQL: HAVING
- CQL: INSERT and UPDATE value in-line formatting
- CQL: Negations in WHERE Clauses
- CQL: Predicate-generated Attribute Values
- CQL: INSERT from SELECT
- CQL Examples
- library(cql/cql): CQL - Constraint Query Language
- Constraint Query Language A high level interface to SQL databases
1.7.44 CQL: Predicate-generated Attribute Values
It is possible to generate compile time attribute values by specifying a predicate which is executed when the CQL statement is compiled.
The predicate must return the value you want as its last argument. You specify the predicate where you would normally put the attribute value. The predicate is specified with its output argument missing.
Example - Using domain allowed values in a query.
In the following CQL statement the predicate cql_domain_allowed_value/3 is called within findall/3 at compile time to generate a list of domain values that restrict favourite_colour to be’ORANGE' or’PINK' or’BLUE', or’GREEN'.
colour('ORANGE'). colour('PINK'). colour('BLUE'). colour('GREEN'). {[], se_lt_x :: [d-findall(Value, permissible_colour(Value)), a-UserName]}
Note how findall/3 is actually called by specifying findall/2.
There is not much point using predicate-generated attribute values in compile-at-runtime CQL as you can always call the predicate to generate the required values outside the CQL statement.