Creating a time series with metadata

You can create an empty or populated time series that also contains user-defined metadata. A time series column includes a header that holds information about the time series and can also contain user-defined metadata.

About this task

User-defined metadata allows the time series to be self-describing. The metadata can be information usually contained in additional columns in the table, such as the name of a stock, or the type of the time series. The advantage of keeping this type of information in the time series is that, when using an API routine, it is easier to retrieve the metadata than to pass additional columns to the routine. Metadata is stored in a distinct type based on the TimeSeriesMeta data type. The TimeSeriesMeta data type is an opaque data type of variable length, up to a maximum length of 512 bytes. The routines that accept the TimeSeriesMeta data type also accept its distinct type. The distinct type requires support functions, such as input, output, send, receive, and so on.

Procedure

To create a time series with metadata:
  1. Create a distinct data type based on the TimeSeriesMeta data type with the following SQL statement. Substitute MyMetaData with a name you choose.
    create distinct type MyMetaData as TimeSeriesMeta
  2. Create support functions for your metadata data type.
    For information on creating support functions, see the Informix® User-Defined Routines and Data Types Developer's Guide.
  3. Run the TSCreate or TSCreateIrr function with the metadata argument.

Results

After you have created a time series with metadata, you can add, change, remove, and retrieve the metadata. You can also retrieve the name of your metadata type.