5.2.7 Sequence Fields

Sequences are basically variable-sized arrays that have a maximum length and carry an additional integer that indicates the current size. The mapping of IDL sequences to a table schema is similar to the array mapping, with the following differences:

  • An extra column is added with the suffix “#length”, used to store the current length of the sequence.
  • The total number of columns created is equal to the maximum number of elements that the sequence can hold, although the number of columns containing valid data at a given time is stored in the “#length” column.
  • The naming convention of adding the suffix “[i]” to each column is required for the Database Integration Service daemon to handle the mapping between IDL and SQL correctly. The open bracket and close bracket characters can be configured using the tags <open_bracket_char> and <close_bracket_char> (see Table 4.8 Database Mapping Options).
  • Sequence elements can contain the NULL value since not all elements may be used at a given time.

Note: Sequences of the IDL types “char”, “wchar” or “octet” map directly into the variable-length SQL types VARCHAR, VARWCHAR, and VARBINARY, respectively. Table 5.8 Sequence Fields in IDL and SQL shows the mapping of a sequence field between IDL and SQL.

Table 5.8 Sequence Fields in IDL and SQL

IDL Type

SQL Table Schema

struct MySequenceContainer {
  long my_key_field; //@key
  sequence<short,4> my_seq_field;
};
CREATE TABLE "MySequenceContainer" (
"my_key_field" INTEGER NOT NULL,
"my_seq_field#length" INTEGER NOT NULL,
"my_seq_field[0]" SMALLINT,
"my_seq_field[1]" SMALLINT,
"my_seq_field[2]" SMALLINT,
"my_seq_field[3]" SMALLINT,
  PRIMARY KEY("my_key_field")
);