next up previous contents index
Next: The View Level Interface Up: Using the Interface Previous: Accessing Tables in Data   Contents   Index

Using the Relation Level Interface

Once the links between tables and predicates have been successfully established, information can then be extracted from these tables using the corresponding predicates. Continuing from the above example, now rows from the table Test can be obtained:

| ?- test(TId, TName, L, P).

TId = t001
TName = X-Ray
L = 5
P = 100

Backtracking can then be used to retrieve the next row of the table Test.

Records with particular field values may be selected in the same way as in Prolog; no mode specification for database predicates is required. For example:

| ?- test(TId, 'X-Ray', L, P).
will automatically generate the query:
SELECT rel1.TId, rel1.TName, rel1.Length, rel1.Price
FROM Test rel1
WHERE rel1.TName = ?
and
| ?- test('NULL'(_), 'X-Ray',  L, P).
generates: (See Section 4.3.7)
SELECT NULL , rel1.TName, rel1.Length, rel1.Price
FROM Test rel1
WHERE rel1.TId IS NULL AND rel1.TName = ?

During the execution of this query the bind variable ? will be bound to the value 'X-Ray'.

Also as a courtesy to Quintus Prolog users we have provided compatibility support for some PRODBI predicates which access tables at a relational level.

| ?- odbc_attach(PredicateName, table(TableName)).

eg. invoke

| ?- odbc_attach(test2, table('Test')).
and then execute
| ?- test2(TId, TName, L, P).
to retrieve the rows.



Luis Fernando P. de Castro 2003-06-27