InsElem 函数

InsElem 函数将元素插入时间系列。

语法

InsElem(ts         TimeSeries, 
       row_value   row,
       flags      integer default 0) 
returns TimeSeries;
ts
要对其执行操作的时间系列。
row_value
要添加到时间系列的行类型值。
flags
flags 参数值中描述了 flags 参数的有效值。缺省值为 0

描述

元素必须是时间系列的具有正确类型的行类型,以有效的时间戳记开头。如果时间系列中已存在具有该时间戳记的元素,那么插入无效并将出现错误。插入完成后,时间系列必须指定给表中的行,否则插入将丢失。

InsElem 仅应在 UPDATE 和 INSERT 语句中使用。如果在 SELECT 语句或限定中使用,那么可能产生不可预测的结果。

不能在时间戳记上插入隐藏的元素。

InsElem 等效的 API 为 ts_ins_elem()

返回结果

已插入元素的新时间系列。

示例

以下示例将元素插入时间系列:
update activity_stocks
set activity_data =
   InsElem(activity_data,
      row('2011-10-06 08:06:56.00000', 6.50, 2000, 
         1, 007, 3, 1)::stock_trade)
where stock_id = 600;