The ts_put_elem() function

The ts_put_elem() function puts new elements into an existing time series.

Syntax

ts_timeseries *
ts_put_elem(ts_tsdesc   *tsdesc, 
             ts_tselem   tselem, 
             mi_datetime *tstamp)
tsdesc
A descriptor of the time series to be modified, returned by ts_open().
tselem
The element to add.
tstamp
The time stamp at which to put the element. The time stamp column of tselem is ignored.

Description

If the time stamp is NULL, the data is appended to the time series (for regular time series) or an error is raised (for irregular time series).

For regular time series, if there is data at the given timepoint, it is updated with the new data; otherwise, the new data is inserted.

For irregular time series, if there is no data at the given timepoint, the new data is inserted. If there is data at the given timepoint, then the following algorithm is used to determine where to place the data:
  1. Round the time stamp up to the next second.
  2. Search backward for the first element less than the new time stamp.
  3. Insert the new data at this time stamp plus 10 microseconds.

The element passed in must match the subtype of the time series.

Hidden elements cannot be updated.

The equivalent SQL function is PutElem.

Returns

The original time series with the element added.