1 library(cql/cql): CQL - Constraint Query Language
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • Constraint Query Language A high level interface to SQL databases
        • library(cql/cql): CQL - Constraint Query Language
          • Warnings from CQL
          • CQL: Retrieved nulls have special logic to handle outer joins
          • CQL: Getting Started Quickly
          • Debugging CQL queries
          • Prolog Variables in CQL queries
          • CQL Special Attributes
          • CQL Examples
          • CQL: Hooks

1.3 CQL: 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)