next up previous contents index
Next: Limitation and Guidelines for Up: Using the Interface Previous: Interface Flags   Contents   Index

Datalog

Users can write recursive Datalog queries with exactly the same semantics as in XSB using imported database predicates or database rules. For example assuming odbc_parent/2 is an imported database predicate, the following recursive query computes its transitive closure.

:- table(ancestor/2).
ancestor(X,Y) :- odbc_parent(X,Y).
ancestor(X,Z) :- ancestor(X,Y), odbc_parent(Y,Z).

This works with drivers that support multiple open cursors to the same connection at the same time. (Sadly, some don't.) In the case of drivers that don't support multiple open cursors, one can often replace each odbc_import-ed predicate call

    ...,predForTable(A,B,C),...
by
    ...,findall([A,B,C],predForTable(A,B,C),PredList),
        member([A,B,C],PredList)...
and get the desired effect.



Luis Fernando P. de Castro 2003-06-27