SQLQuery

SQLQuery(query, …​): bool

Executes SQL statement on the NetXMS server database. The statement is executed for its effect only — no result set is returned, so use it for DELETE, UPDATE, INSERT and similar statements.

This function is available only in housekeeper scripts. Calling it from any other script context fails with a "function not found" error.

If additional arguments are given, the statement is prepared and each argument is bound to the matching ? placeholder in order. Integer arguments are bound as integers, all other values as strings.

Table 1. Parameters

query

String

SQL statement. Use ? placeholders for values supplied as additional arguments.

…​

Any

Optional values for the ? placeholders.

Return

true if the statement was executed successfully, false otherwise.

// Remove rows older than 30 days from a custom table
SQLQuery("DELETE FROM custom_inventory WHERE last_seen < ?", time() - 30 * 86400);