WBEM clients use WQL to query and filter data. When the data is served by a particular provider, the CIMOM passes the client queries to the appropriate provider. You can search for instances that match a specified query in a particular class, or in all classes within a particular name space.
The following example shows a search for all instances of the Solaris_DiskDrive class that have a particular value for the Storage_Capacity property:
select * from Solaris_DiskDrive where Storage_Capacity = 1000
The Solaris WBEM SDK supports Level 1 WBEM SQL, which enables simple select operations without joins. The following table describes the supported WQL key words.
Table 5-2 Supported WQL Key Words
You use the SELECT statement to retrieve instances of a single class and its subclasses. You can also specify the properties to retrieve and the conditions that must be met.
Note - Currently, join operations are not supported.
The syntax for the SELECT statement is as follows:
SELECT list FROM class WHERE condition
The following table shows examples of using arguments in the SELECT clause to refine a search.
Table 5-3 Sample SELECT Statements
The FROM clause identifies the class in which to search for instances that match the query string. Only non-joined expressions are supported, which means that a valid WQL FROM clause includes only a single class.
The FROM clause is represented by the abstract class, fromExp. Currently, NonJoinExp is the only direct subclass of fromExp. The NonJoinExp subclass represents FROM clauses with only one table (CIM class) to which the SELECT operation is applied.
The WHERE clause narrows the scope of a query. This clause contains a conditional expression, that can contain a property or key word, an operator, and a constant.
The syntax for a WHERE clause appended to a SELECT statement is as follows:
SELECT CIMinstance FROM CIMclass WHERE conditional_expression
The conditional_expression in the WHERE clause takes the following form:
property operator constant
The expression is composed of a property or key word, an operator, and a constant. You can append the WHERE clause to the SELECT statement using one of the following forms:
SELECT instance FROM class WHERE constant operator property
Valid WHERE clauses follow these rules:
The value of the constant must be of the correct data type for the property.
The operator must be a valid WQL operator.
Either a property name or a constant must appear on either side of the operator in the WHERE clause.
Arbitrary arithmetic expressions cannot be used. For example, the following query returns only instances of the Solaris_Printer class that represent a printer with ready status:
SELECT * FROM Solaris_Printer WHERE Status = `ready'
Multiple groups of properties, operators, and constants can be combined in a WHERE clause using logical operators and parenthetical expressions. Each group must be joined with the AND, OR, or NOT operators.
The following example retrieves all instances of the Solaris_FileSystem class with the Name property set to either home or files:
SELECT * FROM Solaris_FileSystem WHERE Name= `home' OR Name= `files'
The following example retrieves disks named home and files only if the disks have a certain amount of available space remaining, and have Solaris platform file systems.
SELECT * FROM Solaris_FileSystem WHERE (Name = `home' OR Name = `files') AND AvailableSpace > 2000000 AND FileSystem = `Solaris'
You can use the following standard WQL operators for a binary expression in the WHERE clause of a SELECT statement.
Table 5-4 WQL Operators for WHERE Clauses