Skip to content

TAG data UPDATE WHERE/SET constraints

TAG data UPDATE requires an explicit target scope. WHERE must contain both tag selection and BASETIME predicates, and SET can target only actual data columns.

Supported since Machbase 8.7.0

SET Restrictions

Column roleSET allowedDescription
Data columnYesvalue and auxiliary numeric/string columns
SUMMARIZED data columnYesChanges source TAG row values
BASETIME columnNoTime-axis column cannot change
PRIMARY KEY column (name)NoTag name cannot change
Metadata columnNoUse UPDATE … METADATA separately
Hidden/system columnNoInternal columns are not SET targets

SET expressions allow constants, bind variables, arithmetic/string/CASE expressions without existing-row references, supported conversion functions, and NULL. Existing-row column references, subqueries, and aggregates are unsupported on the right-hand side.

WHERE Restrictions

UPDATE table_name
   SET col = expr
 WHERE name = 'tag-name'
   AND time >= TO_DATE('2026-07-01', 'YYYY-MM-DD');
WHERE predicateSupported
name = '...'Yes
name = ?, name = :tag_nameYes
? = name, :tag_name = nameYes
name IN ('...', '...')Yes
name LIKE '...'Yes
time = t1Yes
time = ?, time = :base_timeYes
? = time, :base_time = timeYes
time BETWEEN t1 AND t2Yes
time >= t1 AND time < t2Yes
time >= ? AND time < ?Yes
One-sided time predicateYes
Data-column predicateYes
No tag selectorNo
No time predicateNo
ORNo
IN (SELECT …)No
Tag/axis column wrapped in a function or expressionNo

Use bind parameters only in predicate value positions. Markers cannot replace tag-name or BASETIME column identifiers, and both tag selection and time predicates remain mandatory. Reexecution selects targets using newly bound values; no match succeeds with 0 affected rows.

For NAME/TIME parameter metadata and SDK APIs, see Bind Parameters in TAG Data UPDATE and Named Bind Parameters.

Metadata UPDATE

UPDATE table_name METADATA
   SET meta_col = value
 WHERE condition;

Metadata UPDATE modifies the tag-attribute area. Its syntax and targets differ from TAG data UPDATE, which modifies data columns in actual time-series rows.

Checking Column Roles

Use DESC to inspect column attributes.

DESC sensor_tag;

Alternatively, query column FLAG values in system tables.

SELECT NAME, TYPE, FLAG
  FROM M$SYS_COLUMNS
 WHERE TABLE_ID = (
     SELECT ID FROM M$SYS_TABLES WHERE NAME = 'SENSOR_TAG'
 );
FLAG valueMeaning
134217728Tag Name
16777216Base Time / Base Distance
33554432Summarized
67108864Metadata

Error Examples

-- Error: BASETIME column used as a SET target
UPDATE sensor_tag
   SET time = TO_DATE('2026-07-01', 'YYYY-MM-DD')
 WHERE name = 'TEMP-01'
   AND time >= TO_DATE('2026-07-01', 'YYYY-MM-DD');

-- Error: missing time predicate
UPDATE sensor_tag
   SET value = 0.0
 WHERE name = 'TEMP-01';

-- Error: OR predicate
UPDATE sensor_tag
   SET value = 0.0
 WHERE name = 'TEMP-01'
    OR name = 'TEMP-02';

Related Documentation

Last updated on