PutElemNoDups function

The PutElemNoDups function inserts a single element into a time series. If there is already an element at the specified timepoint, it is replaced by the new element.

Syntax

PutElemNoDups(ts         TimeSeries, 
             row_value  row,
             flags      integer default 0) 
returns TimeSeries;
ts
The time series to act on.
row_value
The new row type value to store in the time series.
flags
Valid values for the flags argument are described in The flags argument values. The default is 0.

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).

If there is data at the given timepoint, it is updated with the new data; otherwise, the new data is inserted.

The row type passed in must match the subtype of the time series.

Hidden elements cannot be updated.

The API equivalent of PutElemNoDups is ts_put_elem_no_dups().

Returns

A modified time series that includes the new values.

Example

The following example updates a time series:
update activity_stocks
set activity_data = PutElemNoDups(activity_data,
   row('2011-08-25 09:06:00.00000', 6.25, 
      1000, 1, 007, 2, 1)::stock_trade)
   where stock_id = 600;