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:
SELECT rel1.TId, rel1.TName, rel1.Length, rel1.Price FROM Test rel1 WHERE rel1.TName = ? ;and
generates: (See Section 7.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 'X-Ray'.
Note that if a field includes a quote then this should be represented by using two quotes.
Also as a courtesy to Quintus Prolog users we have provided compatibility support for some PRODBI predicates which access tables at a relational level.
i) | ?- odbc_attach(PredicateName, table(TableName)).
eg. invoke
ii) | ?- odbc_record('Test', R). R = [t001, X-Ray, 5, 100]; R = ...You can use odbc_record/2 to treat the whole database row as a single list structure.