Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » UltraLite - C and C++ Programming » Developing Applications Using the UltraLite C++ API » Accessing data with the Table API

Accessing data with the Table API Next Page

Navigating the rows of a table

The UltraLite C++ API provides you with a number of methods to navigate a table to perform a wide range of navigation tasks.

The table object provides you with the following methods to navigate a table:

See UltraLite_Table_iface class.


The following code opens the table named MyTable and displays the value of the column named MyColumn for each row.

Table * tbl = conn->openTable( "MyTable" );
ul_column_num colID = 
   tbl->GetSchema()->GetColumnID( "MyColumn" );

while ( tbl->Next() ){
   char buffer[ MAX_NAME_LEN ];
   ULValue colValue = tbl->Get(colID);
   colValue.GetString(buffer, MAX_NAME_LEN);
   printf( "%s\n", buffer );

You expose the rows of the table to the application when you open the table object. By default, the rows are ordered by primary key value, but you can specify an index when opening a table to access the rows in a particular order.


The following code fragment moves to the first row of the MyTable table as ordered by the ix_col index.

ULValue table_name( UL_TEXT("MyTable") )
ULValue index_name( UL_TEXT("ix_col") )
Table * tbl = 
   conn->OpenTableWithIndex( table_name, index_name );

See UltraLite_Table_iface class.