Assuming you have access permission for the table you wish to import, you can use db_import/2 as:
| ?- db_import('DEPT'('DEPTNO','DNAME','LOC'),dept). yes | ?- dept(Deptno, Dname, Loc). Deptno = 10 Dname = ACCOUNTING Loc = NEW YORK
Backtracking can then be used to retrieve the next row of the table DEPT.
Records with particular field values may be selected in the same way as in Prolog. (In particular, no mode specification for database predicates is required). For example:
SELECT DEPTNO, LOC FROM DEPT rel1 WHERE rel1.DNAME = :BIND1;and
SELECT NULL , rel1.DNAME , rel1.LOC FROM DEPT rel1 WHERE rel1.DEPTNO IS NULL AND rel1.DNAME = :BIND1;During the execution of this query the :BIND1 variable will be bound to 'ACCOUNTING'.
Note that the relation level interface can be used to define and access simple project views of single tables. For example:
The predicate db_import/2 and other Oracle interface predicates automatically asserts data dictionary information. You can use the Prolog predicate listing/2 to see the asserted data dictionary information at any time.
Note: as a courtesy to Quintus Prolog users we have provided compatibility support for some PRODBI predicates which access tables at a relational level.
i) | ?- db_attach(Pname, table(Tablename)).
ii) | ?- db_record('DEPT', R). R = [20,RESEARCH,DALLAS]; R = ...You can use db_record/2 to treat the whole database row as a single list structure.