1.3 Getting Started Quickly
Here is a simple example of a SQL SELECT from the table se_lt_x
test(A) :- format('About to call CQL with A=~w', [A]), {[], se_lt_x :: [a-A, b-B, c-C]}, format('B=~w, C=~w', [B, C]).
- The CQL is distinguished from the ordinary Prolog by appearing in curly brackets
- Prolog variables which are ground when the CQL is executed will appear in the resulting SQL as part of the WHERE clause
Comparisons can be done in-line e.g.
[a-'ELSTON_M']
or with the ==
operator e.g.
[a-A], A == 'ELSTON_M'.
The single = operator means unify, not compare. Use = for unification, not comparison
FIXME: Unification is deprecated.
The operators =:=
and \==
are also
available for numerical value comparisons (they just translate to SQL =
and <>
, so in fact you could use them for string
comparisons)