此内容没有您所选择的语言版本。
8.3. How to Access the Data?
This section describes how to access the data. For example, assume you have a vdb by name northwind deployed and that vdb has a table customers in a model called NW. You can access the table as:
http://localhost:8080/odata/northwind.1/NW.customers
http://localhost:8080/odata/northwind.1/NW.customers
This is similar to making a JDBC/ODBC connection and issuing a SQL call as
SELECT * FROM NW.customers
SELECT * FROM NW.customers
Note
You need to fully qualify the table name along with the model name. Also, use correct case (upper or lower) as used in the VDB.
The returned results from OData query can be in Atom/AtomPub XML format or JSON format. By default AtomPub based XML result is returned.
Note
When you issue the above query if you receive a message similar to:
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <code>NotFoundException</code> <message lang="en-US">EdmEntitySet NW.customer is not found</message> </error>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>NotFoundException</code>
<message lang="en-US">EdmEntitySet NW.customer is not found</message>
</error>
Then, it means that either you supplied the model-name.table-name combination wrong, in that case, check spelling and case. Or your table did not have any PRIMARY KEY or UNIQUE KEY(s) on them. Since OData access is more key oriented, it is mandatory that every table Teiid exposes through OData interface must have a PK or at least one UNIQUE key.
Teiid does support composite PRIMARY KEY too.
If you are not able to see all the rows, then see the configuration section below for more details. Issue another call as:
http://localhost:8080/odata/northwind.1/NW.customers?$skiptoken=256
http://localhost:8080/odata/northwind.1/NW.customers?$skiptoken=256
You can also submit criteria with along the query to filter the results:
http://localhost:8080/odata/northwind.1/NW.customers?$filter=name eq 'bob'
http://localhost:8080/odata/northwind.1/NW.customers?$filter=name eq 'bob'
This is similar to making a JDBC/ODBC connection and issuing a SQL call as:
SELECT * FROM NW.customers where name = 'bob'
SELECT * FROM NW.customers where name = 'bob'
The power of OData querying comes from navigations from one entity to another, similar to the foreign key relationships in the relational databases. For example, if customers table had a association with orders table, where say customers table had primary key of ID then, you can issue a query:
http://localhost:8080/odata/northwind.1/NW.customers(1234)/NW.orders?$filter=orderdate > '12-31-2012'
http://localhost:8080/odata/northwind.1/NW.customers(1234)/NW.orders?$filter=orderdate > '12-31-2012'
This is similar to making a JDBC/ODBC connection and issuing a SQL call as:
SELECT * FROM NW.orders o join NW.customers c join o.customer_id = c.id where c.id=1234 and o.orderdate > '12-31-2012'
SELECT * FROM NW.orders o join NW.customers c join o.customer_id = c.id where c.id=1234 and o.orderdate > '12-31-2012'