Data Access User Manual > Rogue Wave Views Data Access Common Framework > Tables > Schemas > Defining the Schema of a Table Object
 
Defining the Schema of a Table Object
This section shows how a table can be created and its schema defined. Since the IliTable class is abstract and therefore cannot be instantiated, the IliMemoryTable class is used in the example below.
The IliMemoryTable class implements the table interface by storing rows in the process memory space. Therefore, this class is suitable for transient tables that do not retain their states across program executions.
A number of member functions let you access or modify the schema of a table. Most of these can be found in the description of the IliSchema class. See Rogue Wave Views Data Access Reference Manual. The IliTable class defines those member functions that deal specifically with the mapping of columns.
Here is a list of some of the schema member functions :
class IliSchema {
...
IlInt getColumnsCount() const;
const char* getColumnName(IlInt colno) const;
const IliDatatype* getColumnType(IlInt colno) const;
IlBoolean isColumnPartOfKey(IlInt colno) const;
void setColumnPartOfKey (IlInt colno, IlBoolean partOfKey);
IlBoolean isColumnNullable(IlInt colno) const;
void setColumnNullable(IlInt colno, IlBoolean nullable);
IlBoolean insertColumn(IlInt colno,
const char* colname,
const IliDatatype* type,
IlInt maxlen = -1);
};
The following code shows how a memory table can be defined:
enum ColumnTag { IdColumn, NameColumn, SalaryColumn };
IlvDisplay* display;
...
IliMemoryTable* tbl = new IliMemoryTable(display);
tbl->lock();
tbl->insertColumn(IdColumn, “Id”, IliIntegerType);
tbl->insertColumn(NameColumn, “Name”, IliStringType);
tbl->insertColumn(SalaryColumn, “Salary”, IliDoubleType);
tbl->setColumnPartOfKey(IdColumn, IlvTrue);
tbl->unLock();
In this example, a memory table is created and its schema is defined. The schema has three columns, one of which serves as a key for the table. The IliSchema::insertColumn and IliSchema::setColumnPartOfKey member functions are used.
Note that the IliMemoryTable class like all classes derived from the IliSchema class is reference counted. This means that it is necessary to lock instances of these classes when they are used. An instance of these classes is implicitly deleted when its reference count reaches 0.
The next section contains information on how to access or edit the rows of a table. The IliTableBuffer class is the main class required to carry out these actions.

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.