Contents Index Data manipulation internals Accessing the values of the current row

UltraLite C++ User's Guide
  Understanding UltraLite Development
    Accessing and manipulating data with the Table API

Scrolling through the rows of a table


The following code opens the MyTable table and scrolls through its rows, displaying the value of the MyColumn column for each row.

Table * t = conn->openTable( "MyTable" );
ul_column_num colValue = 
   t->GetSchema()->GetColumnID( "MyColumn" );
while ( t->Next() ){
   char lname[ MAX_NAME_LEN ];
   printf( "%s\n", colValue );
}

You expose the rows of the table to the application when you open the table object. By default, the rows are exposed in order by primary key value, but you can specify an index to access the rows in a particular order. The following code moves to the first row of the MyTable table as ordered by the ix_col index.

ULValue table_name( "MyTable" )
ULValue index_name( "ix_col" )
Table * t = 
   conn->OpenTableWithIndex( table_name, index_name );
t.moveFirst();

For more information, see Table TableSchema and Connection in the online API Reference.


Contents Index Data manipulation internals Accessing the values of the current row