Update Query Language
The Update Query Language (UpdateQL) supports three commands: INSERT INTO, DELETE FROM, and UPDATE. These commands respectively permit the insertion, deletion, and manipulation of a WMI object instance.
The following example shows the syntax of the INSERT INTO, DELETE FROM, and UPDATE commands.
INSERT INTO <className> (propName1,...propNameN)(value1...valueN) DELETE FROM <className> WHERE <condition> UPDATE <className> SET propName1 = value1,...propNameN = valueN WHERE <condition>
Note For more information about support and installation of this component on a specific operating system, see Operating System Availability of WMI Components.
UpdateQL supports the use of well-known aliases to refer to intrinsic objects and their properties. Such an object would be the event object which is supplied when an event notification occurs to an event consumer. The only way to refer to this object and its properties is through a well-known alias. For example, to express the statement "Update Property A of Instances of class X with the value of the Property B of the triggering Event Object" you must use the alias __THISEVENT in the UpdateQL statement.
The following example shows the syntax of the UpdateQL statement using the __THISEVENT alias.
UPDATE X SET A = __THISEVENT.B
Intrinsic object aliases may also be used to identify objects selected through a data query. In SQL, this is normally done using SELECT statements nested inside an UPDATE statement.
The following example shows how use intrinsic object aliases to identify objects through a query using a SQL statement.
UPDATE X SET A = ( SELECT B FROM Y WHERE Id = "1233" )
In UpdateQL, this must be done with two separate statements, the first selecting the data and the second updating the selected data through the well-known alias __THISDATA.
The following example shows the UpdateQL equivalent of the preceding SQL statement.
SELECT * FROM Y WHERE Id = "1233" UPDATE X SET A = __THISDATA.B
UpdateQL supports the five binary operators +, -, *, /, and % and the two unary operators + and -. UpdateQL only supports the use of arithmetic expressions in assignments, not in WHERE clauses. If an arithmetic expression is needed in the WHERE clause of a query, it must be done using two statements: the first being an update query performing the desired arithmetic operation and saving the result in a temporary variable, and then the second query then referencing this variable in the WHERE clause.
The following example shows the use of operators in the UPDATE statement.
UPDATE ClassA SET Temp = __THISEVENT.Y + 2 UPDATE ClassA SET A = TRUE WHERE X < Temp
Entire objects can be used on the right side of assignments as well as in the values specification in the INSERT INTO statement. For example, __THISDATA and __THISEVENT are valid r-values and __THIS is a valid l-value.
Logical operators are only supported in the WHERE clause.
UpdateQL supports manipulation of time and interval properties, including arithmetic operations on time and interval properties. Time and time intervals may be represented using CIM_DATETIME or a 64-bit numeric property. As a 64-bit numeric property, time is interpreted as the number of seconds since January 1, 1601. Internally, time and time intervals are represented as an 80-bit double-precision value specifying the number of seconds since January 1, 1601. UpdateQL supports conversion from this 80-bit format to CIM_DATETIME and to 64-bit format. UpdateQL obtains the current time using the __NOW alias.
In addition to creating, updating, and manipulating instances, UpdateQL is able to fire events. This is done using the INSERT INTO statement with the class named after the INSERT INTO clause being an extrinsic event class. This causes a corresponding event to be fired after the object is constructed. Events fired must be derived from the MSFT_UCEventBase class.