TSCreate function

The TSCreate function creates an empty regular time series or a regular time series populated with the given set of data. The new time series can also have user-defined metadata attached to it.

Syntax

TSCreate(cal_name       lvarchar, 
         origin         datetime year to fraction(5), 
         threshold      integer, 
         zero           integer, 
         nelems         integer, 
         container_name  lvarchar) 
returns TimeSeries with (handlesnulls);

TSCreate(cal_name       lvarchar, 
         origin         datetime year to fraction(5), 
         threshold      integer, 
         zero           integer, 
         nelems         integer, 
         container_name lvarchar, 
         set_rows       set) 
returns TimeSeries with (handlesnulls);

TSCreate(cal_name       lvarchar, 
         origin         datetime year to fraction(5), 
         threshold      integer, 
         zero           integer, 
         nelems         integer, 
         container_name lvarchar, 
         metadata       TimeSeriesMeta) 
returns TimeSeries with (handlesnulls);

TSCreate(cal_name       lvarchar, 
         origin         datetime year to fraction(5), 
         threshold      integer, 
         zero           integer, 
         nelems         integer, 
         container_name lvarchar, 
         metadata       TimeSeriesMeta, 
         set_rows       set) 
returns TimeSeries with (handlesnulls);
cal_name
The name of the calendar for the time series.
origin
The origin of the time series. This is the first valid date from the calendar for which data can be stored in the series.
threshold
The threshold for the time series. If the time series stores more than this number of elements, it is converted to a container. Otherwise, it is stored directly in the row that contains it, not in a container. The default is 20. The size of a row containing an in-row time series should not exceed 1500 bytes.

If a time series has too many bytes to fit in a row before this threshold is reached, the time series is put into a container at that point.

zero
Must be 0.
nelems
The number of elements allocated for the resultant time series. If the number of elements exceeds this value, the time series is expanded through reallocation.
container_name
The name of the container used to store the time series. Can be NULL.
metadata
The user-defined metadata to be put into the time series. See Creating a time series with metadata for more information about metadata.
set_rows
A set of row type values used to populate the time series. The type of these rows must be the same as the subtype of the time series.

Description

If TSCreate is called with a metadata argument, then the metadata is saved in the time series.

Returns

A regular time series that is empty or populated with the given set and optionally contains user-defined metadata.

Example

The following example creates an empty time series using TSCreate:
insert into daily_stocks values(
   901,'HCLTECH', TSCreate('daycal',
      '2011-01-03 00:00:00.00000',20,0,0, NULL));
The following example creates a populated regular time series using TSCreate:
select TSCreate('daycal',
      '2011-01-05 00:00:00.00000',
      20,
      0,
      NULL,
      set_data)::TimeSeries(stock_trade)
    from activity_load_tab
    where stock_id = 600;