next up previous contents index
Next: Using the Relation Level Up: Using the Interface Previous: Connecting to and Disconnecting   Contents   Index

Accessing Tables in Data Sources

There are several ways that can be used to extract information from or modify a table in a data source. Users can access a table using the relation level interface or view level interface which XSB provides or they can have their SQL statements executed directly without having XSB process it. In general, uses are required to firstly use odbc_import/2 to give XSB the information about columns in the table of interest, expect for the cases such as direct execution of SQL statements and data dictionary operations, etc. and XSB will automatically assert data dictionary information$($some other ODBC interface predicates can cause XSB to do this too$)$. The Prolog predicate listing/2 can be used $($if it's available$)$ to see the asserted data dictionary information at any time.

The syntax of odbc_import/2 is as follows:

| ?- odbc_import('TableName'('FIELD1', 'FIELD2', ..., 'FIELDn'), 'PredicateName').

where 'TableName' is the name of the table that is desired for accessing and 'PredicateName' is the name of the predicate for future table operations from XSB. 'FIELD1', 'FIELD2', ... , 'FIELDn' are the exact attribute names$($case sensitive$)$ as defined in the table schema. The chosen columns define the view and the order of arguments for the database predicate 'PredicateName'.

For example, to create a link to the Test table through the 'test' predicate:


| ?- odbc_import('Test'('TId','TName','Length','Price'),test).

yes


next up previous contents index
Next: Using the Relation Level Up: Using the Interface Previous: Connecting to and Disconnecting   Contents   Index
Baoqiu Cui
2000-04-23