Creating a User Defined Table: Tutorial

This tutorial shows you how to create a user defined table. The tutorial, then shows you how to store a new record.


This tutorial shows you:

  • how to create a user defined table

  • how to create a user defined record and store that record in the table


Before you start, you must understand:

  • the general concept of the Comms Database

  • the specific concepts of fields, records, links and tables

  • how to write and build application code to run on Symbian platform


  1. Make sure that you have created a session.

  2. Define a schema for the new table.

    Create an array of [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]SGenericRecordTypeInfo items. Each SGenericRecordTypeInfo item defines a field in the record.
    const SGenericRecordTypeInfo recordInfo[] =
  3. Define a name for the table.

  4. Create a [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]CMDBGenericRecord object.

    A [[[ERROR: [NOKX000E] Unable to find definition for key reference 'CommsDat']]]CMDBGenericRecord object represents a record and a set of records Give the object the name of the table and the name of the schema.
    // Record factory creates the CMDBGenericRecord object. The KCDNewTableRequest value 
    // passed to the record factory allocates a new table Id.
    CMDBGenericRecord* ptrNewTable = 
    // Initialise with the name of the table and the name of the schema.
  5. Access fields in the record.

    The code uses GetFieldByNameL() and GetFieldByIdL().
    TInt valueType;
    CMDBElement* LanType = ptrNewTable-> GetFieldByNameL(KNameWLANType, valueType);
    CMDBElement* RecordName = ptrNewTable->GetFieldByIdL(KCDTIdRecordName);
  6. Change the valuie of the fields and create a new record.

    // Cast the field objects to the appropriate type
    CMDBField<TUint32>* LanTypefield = static_cast<CMDBField<TUint32>*>(LanType);
    CMDBField<TDesC>* RecordNamefield = static_cast<CMDBField<TDesC>*>(RecordName);
    // Change the field value
    *LanTypefield = 100;
    // Change the field value
    _LIT(KNewName, " NewName ");
    *RecordNamefield = KNewName();
    // Can also use this format: RecordNamefield->SetL(KNewName());
    // Asks for a new record
    // Stores the new record

Related concepts