3.1.1.2.4 Algorithm (Recursive) for Encoding a RecordSet into a TableGram

This algorithm describes how a RecordSet can be encoded into a TableGram. The algorithm is recursive.

A table description needs to be encoded in an adtgTableDescriptor (section 2.2.3.14.3.3). The adtgTableDescriptor MUST contain:

  • Table Name: Set to the name of the table. Table Name MUST be unique.

  • ColumnCount: Set to the number of columns in this table.

  • KeyColumnInfo: An ordered list of the ordinal of the columns that make the key.

  • KeyColumnCount: The number of IsKey columns in this table.

  • CodePage: The LCID of the data contained in any string values.

For each column in the table, the column metadata is encoded in the adtgColumnDescriptorCommon, adtgColumnDescriptorParent, or adtgColumnDescriptorChild. The column metadata MUST contain the following:

  • Column Ordinal

  • ColumnDescriptor Map: A bitmap that contains a bit set to '1' for each optional column descriptor encoded in the metadata.

  • Datatype

  • Precision

  • Scale

  • Column Flags

The column metadata can contain:

  • Column Name: Set the name of the column. Column Name MUST be unique.

For additional column metadata that MAY<69> be sent, see section 2.2.3.14.3.6.

Applications MUST be able to process the columns if any of the optional columns are not present in the TableGram.

If the column is an IsChaptered column, the column is a placeholder in the table for the child RecordSet. Chapter columns MUST include RelationConditions, CalculationInfo, and adtgColumnChildRecordSetId.

For each row in the table, the row is encoded as record (see section 2.2.3.14.4.4) adtgParentUnchanged for a parent RecordSet and encoded as record adtgChildUnChanged (section 2.2.3.14.4.8) for a child RecordSet. For each column in that row, a field is encoded into the adtgParentUnchanged or adtgChildUnChanged.

For each IsChaptered column in the table, encode the child RecordSet. The child RecordSet is encoded by applying the algorithm to the child table.