Retrieving a Single Row

Construct a handle for the table from which you want to
read. You do this by retrieving a
TableAPI class instance using
KVStore.getTableAPI(). You then
use that instance to retrieve the desired table handle
using TableAPI.getTable(). This
returns a Table class instance.

Use the Table instance
retrieved in the previous step to create a
PrimaryKey class instance. In
this case, the key you create must be the entire
primary key.

Retrieve the row using TableAPI.get().
This performs a store read operation.

package kvstore.basicExample;
import oracle.kv.KVStore;
import oracle.kv.table.PrimaryKey;
import oracle.kv.table.Row;
import oracle.kv.table.Table;
import oracle.kv.table.TableAPI;
...
// KVStore handle creation is omitted for brevity
...
TableAPI tableH = kvstore.getTableAPI();
// The name you give to getTable() must be identical
// to the name that you gave the table when you created
// the table using the CLI's 'table create' command.
Table myTable = tableH.getTable("myTable");
// Construct the PrimaryKey. This is driven by your table
// design, which designated one or more fields as
// being part of the table's primary key. In this
// case, we have a single field primary key, which is the
// 'item' field. Specifically, we want to retrieve the
// row where the 'item' field contains 'Bolts'.
PrimaryKey key = myTable.createPrimaryKey();
key.put("item", "Bolts");
// Retrieve the row. This performs a store read operation.
// Exception handling is skipped for this trivial example.
Row row = tableH.get(key, null);
// Now retrieve the individual fields from the row.
String item = row.get("item").asString.get();
String description = row.get("description").asString.get();
Integer count = row.get("count").asInteger.get();
Double percentage = row.get("percentage").asDouble.get();

Retrieve a Child Table

In Writing Rows to a Child Table
we showed how to populate a child table with data. To
retrieve that data, you must specify the primary key used
for the parent table row, as well as the primary key for
the child table row. For example: