Show allShow sourcesql_compiler.pro -- Mapping of prolog terms to SQL

Description

This module rewrites prolog goals as SQL goals. It assumes the details of the schema are given using the following predicates:

tree(?ID,?Parent)

struct(ID,Parent) :- struct(ID,Parent).
struct(ID,A) :- struct(ID,Parent),struct(Parent,A).

should translate to:

WITH RECURSIVE struct AS (
SELECT t.* FROM tree t WHERE id = 890
UNION ALL
SELECT t.* FROM tree t, struct s WHERE t.id = s.parent_id
)
SELECT * FROM struct;

Copyright

This Prolog to SQL compiler may be distributed free of charge provided that it is not used in commercial applications without written consent of the author, and that the copyright notice remains unchanged.

(C) Copyright by Christoph Draxler, Munich Version 1.1 of Dec. 21st 1992

I would like to keep in my hands the further development and distribution of the compiler. This does not mean that I don't want other people to suggest or even implement improvements - quite on the contrary: I greatly appreciate contributions and if they make sense to me I will incorporate them into the compiler (with due credits given!).

For further development of the compiler, address your requests, comments and criticism to the author:

Christoph Draxler CIS Centre for Information and Speech Processing Ludwig-Maximilians-University Munich Wagmuellerstr. 23 D 80538 Munich Tel : ++49 / +89 / 211 06 64 (-60) Fax : ++49 / +89 / 211 06 74 Mail: draxler@cis.uni-muenchen.de

A report describing the implementation is available upon request from the author.

RELEASE INFORMATION Current version is v. 1.1 of Dec. 21st 1992. Version 1.0 Sept. 3 1992 CJM mods 2005

load_schema_defs(+SchemaFileSpec)
loads a schema into memory, allowing sql_compiler to make use of it for plterm_to_sqlterm/3

Example: load_schema_defs(bio('sql_schema/schema_enscore44'))

plterm_to_sqlterm(+ProjectionTerm, +DatabaseGoal, ?SQLQueryTerm)
rewrite a prolog goal as a SQL Term. The SQL term can then be translated via sqlterm2atom/2
Parameters:
ProjectionTerm-
DatabaseGoal-
SQLQueryTerm-
rewrite_query(+GoalIn, ?GoalOut) is det
sqlterm2atom(+SQLQueryTerm, ?SQLQueryAtom) is det
translates an SQL Term to an atom that conforms to SQL syntax. see plterm_to_sqlterm/3 [Ciao: sqlterm2string]
get_type(+Constant, ?Type)
Prolog implementation specific definition of type retrieval sepia Prolog version given here

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

print_sqlterm(Arg1)