PrologSQL: SWI-Prolog to SQL bridge. #
- Prolog to ORACLE.
- Prolog to ODBC.
This project was originally hosted at geocities.
This is a very old project. It was originally developed in February of 2000.
PrologSQL main features #
- PrologSQL is a SWI-Prolog to SQL bridge, i.e. program that converts Prolog predicate calls to SQL queries and send them to ORACLE or ODBC.
- The Prolog - Oracle interface provides the programmer with two levels of interaction. The first, relation level interface, offers a tuple-at-a-time retrieval of information from the database tables. The second, view level interface, can translate an entire Prolog clause into a single SQL query to the database, including joins and aggregate operations.
- This interface allows database tables to be accessed from Prolog environment as though they existed as facts. All database accesses are done on the fly allowing Prolog to sit alongside other concurrent tasks.
- PrologSQL interface gives an database programmer all the features of Prolog as a query language including intensional database specification, recursion, the ability to deal with incomplete knowledge, inference control through the cut operation, and the representation of negative knowledge through negation.
- Interface features
- Concurrent access for multiple Prolog systems to Oracle 8.*
- Full data access and cursor transparency including support for
- Full data recursion
- Runtime type checking
- Automatic handling of NULL values for insertion, deletion and querying
- Partial recovery for cursor losses due to cuts
- Full access to Oracle’s SQLplus including
- Transaction support
- Cursor reuse for cached SQL statements with bind variables (by avoiding re-parsing and re-declaring).
- Caching compiler generated SQL statements with bind variables and efficient cursor management for cached statements
- A powerful Prolog/SQL compiler
- Full source code availability for ports to other versions of Oracle or other platforms
- Independence from database schema by employing relation level
- Performance as SQL by employing view level
- No mode specification is required for optimized view compilation
- PrologSQL is distributed under GNU public license.
- PrologSQL is derieved from XSB - Oracle Interface By Hassan Davulcu and Ernie Johnson.
- XSB - Oracle Interface uses a powerful Prolog/SQL compiler from Christoph Draxler, Munich.
- Oracle and Odbc Template Library from Sergei Kuchinis is used as a low level database access engine.
- Short description of predicates
- Because PrologSQL is derieved from XSB - database interface, it is the best way to look at XSB - Oracle Interface at the moment.
- Simple example
- Import two tables from a database.
- Create a nondeterministic query predicate as an join between two tables.
- Call the query predicate.
:- use_module(oracle). go :- db_open('Your Database Name', 'scott', 'tiger'), db_import('DEPT'('DEPTNO', 'DNAME', 'LOC'), dept), db_import('EMP'('EMPNO', 'ENAME', 'JOB', 'MGR', 'HIREDATE', 'SAL', 'COMM', 'DEPTNO'), emp), %% Uncomment it, if you do not want to see SQL statements. %% db_flag(show_query, _, off), db_query(empinfo(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, DNAME, LOC), ( emp(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO), dept(DEPTNO, DNAME, LOC) ) ), get_result, db_close. get_result:- empinfo(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, DNAME, LOC), write_ln([EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, DNAME, LOC]), fail. get_result.
Known bugs and limitations #
- It is possible to connect to only one database.
- Weak error reporting :-(
Download PrologSQL #
- PrologSQL-0.2.3.zip Windows binaries + Source Code
- Unzip archive to a temporary directory.
- Copy files OracleProlog.dll, oracle.pl, ODBCProlog.dll, odbc.pl, PrologSQL.pl to your working directory or to prolog search path.