Delete Historical Data (C)
Regulatory Requirements
Data deletion is a highly sensitive operation. Regulated industries (pharmaceuticals, food, etc.) typically require that data “never be deleted” or that “deletions must be auditable.” Server-side implementations may include additional safeguards.
DeleteRange
Delete data points by time interval.
OPCUA_API DarraUa_Status OPCUA_CALL DarraUa_Session_HistoryDeleteRange(
DarraUa_SessionHandle h,
const char* node_id_str,
DarraUa_DateTime start_time,
DarraUa_DateTime end_time,
DarraUa_Boolean is_delete_modified);
| Parameters | Note |
|---|---|
| is_delete_modified | 0 = Delete raw history; 1 = Delete modified history (modification records) |
#include <opcua/opcua_history.h>
DarraUa_DateTime end = utc_now_ft() - 7LL * 864000000000LL; /* 7 days ago */
DarraUa_DateTime start = utc_now_ft() - 30LL * 864000000000LL; /* 30 days ago */
DarraUa_Status st = DarraUa_Session_HistoryDeleteRange(
h, "ns=2;s=Temperature",
start, end,
/*is_delete_modified*/ 0);
if (!UA_STATUS_IS_GOOD(st))
fprintf(stderr, "DeleteRange failed: %s\n", DarraUa_StatusName(st));
Deletion at a Specific Time / Event Deletion
Dedicated Not currently API available.
- Delete by exact timestamp: Use
DarraUa_Session_HistoryDeleteRangeto delete by time range, or useDarraUa_Session_HistoryUpdateData'supdate_type = 4(Remove) function; in this case, the arrayvalueswill only include the fieldSourceTimestamp. - Delete by Event: Not currently available.
Audit Requirements
- According to certain on-site regulations, data can only be marked as invalid; it must not be physically deleted.
- Deletion actions must be logged for auditing purposes (who deleted it, when, and why); this is to be implemented by the server.
The server-side implementation may include additional safeguards, while the client-side may receive UA_STATUS_BAD_USER_ACCESS_DENIED.
Calls and Timeouts
- One call = one synchronization RPC; the server returns one response.
HistoryUpdateResult - Wait Timeout =
DarraUa_SessionConfig.request_timeout_ms(single RPC, default 5 seconds); returns on timeoutUA_STATUS_BAD_TIMEOUT