Product Documentation

FairCom ODK Driver

Previous Topic

Next Topic

TableCreate

Creates a new table in the database.

  • Each record in a table can contain up to 2 billion bytes.
  • A common record size is between 50 and 8000 bytes.

void FCODKDriver::TableCreate(const char *tableName, unsigned char pkLen, unsigned char retentionUnit, const char *retentionMeasure)

Parameters:

  • IO Channel Number - A one-byte unsigned integer number between 0 and 31. The default is 0.

    Invalid Value Error Conditions:

    • IO Channel Number is greater than 31.
  • tableName [IN] - Table Name. All operations on a table use the Table Name to identify the table.

    A Table Name must:

    • be 64 bytes or less
    • contain only ASCII letters, digits, or underscore “_”
    • start with an ASCII letter (A-Z or a-z)

    If the name is less than 64 bytes, which will often be the case, the byte following the end of the name must be set to NULL.

    If the name is 64 bytes, then the NULL character does not and cannot exist at the end.

    Invalid Value Error Conditions:

    • Does not match an existing table name.
    • Table Name cannot be NULL.
    • Contains unacceptable byte values.
  • pkLen [IN] - Primary Key Length. Primary Key Length is an unsigned one-byte integer between 1 and 255.

    A zero-length Primary Key is not allowed.

    A Primary Key has a fixed length.

    The length cannot be changed after the table is created.

    The length must be large enough to uniquely identify each record in a table.

    • A length of 1 byte has the potential to uniquely identify 256 records.
    • A length of 2 bytes has the potential to uniquely identify 65,536 records.
    • A length of 3 bytes has the potential to uniquely identify 16,777,216 records.
    • A length of 4 bytes has the potential to uniquely identify 4,294,967,296‬ records.

    The database automatically creates an index on the Primary Key when a table is created.

    The index makes looking up records in the table fast and efficient.

    When a Primary Key is shorter than the Primary Key Length, you must pad the unused bytes at the end with NULL.

    Invalid Value Error Conditions:

    • Primary Key Length is not between 1 and 255.
    • Primary Key is NULL.
  • retentionUnit [IN] - Retention Unit is a one-byte unsigned integer number between 1 and 255.

    The default is 13. Thus, when the value is NULL, the driver uses 13.

    For best performance, this number should not exceed 25.

    Invalid Value Error Conditions:

    • Retention Unit is not between 1 and 255.
  • retentionMeasure [IN] - Retention Measure. One of the following ASCII strings (without the quotes and padded with zero at the end to a fixed size of 6 bytes):

    "year "

    "month "

    "day "

    "hour "

    "minute"

    The default is "month". Thus, when the value is NULL, the driver uses "month".

    Retention Unit and Retention Measure work together to define the Retention Period, such as 13 months.

    Invalid Value Error Conditions:

    • Retention Measure is not set to one of the specified strings.

Result Values: N/A

Expected Errors:

  • Table with the specified name already exists.

When an Error Occurs:

  • Driver does not create the table.

TOCIndex