Load small amounts of data with SQL functions
You can load individual elements or sets of elements by using time series SQL functions.
Use any of the following functions to load data into a
time series:
- PutElem
- Updates a time series with a single element.
- PutSet
- Updates a time series with a set of elements.
- InsElem
- Inserts an element into a time series.
- InsSet
- Inserts every element of a specified set into a time series.
These functions add or update an element or
set of elements to the time series. They must be used in an SQL UPDATE
statement with the SET clause:
update table_name
set TimeSeries_col=FunctionName(TimeSeries_type, data)
where col1='value';
The TimeSeries_col argument is the name of the column in which the time series is located. The FunctionName argument is the name of the function. The data argument is in the row type data element format. The WHERE clause specifies which row in the table to update.
The following example appends
an element to a time series by running the PutElem function:
update daily_stocks
set stock_data = PutElem(stock_data,
row(NULL::datetime year to fraction(5),
2.3, 3.4, 5.6, 67)::stock_bar)
where stock_name = 'IBM';
You can also use more complicated expressions to load a time series, for example, by including binary arithmetic functions.