![]() |
![]() |
| ||||||||||||||||||||||||||||||||||||||||
Chapter 5Writing WBEM QueriesThis chapter explains how to use the WBEM Query Language (WQL) and the query APIs to write queries. The chapter includes the following topics: Note - For detailed information on the WBEM query APIs in javax.wbem.query, see file:/usr/sadm/lib/wbem/doc/index.html. About the WBEM Query LanguageThe WBEM Query Language (WQL) is a subset of the standard American National Standards Institute Structured Query Language (ANSI SQL). WQL has semantic changes to support WBEM in the Solaris environment. The following table shows the mapping of SQL concepts to WQL. Table 5-1 Mapping of SQL Concepts to WQL
Note - Like SQL, WQL statements use single (` ') quotation marks. In the implementation of Solaris WBEM Services, WQL is a retrieval-only language. You can use WQL to query data that is stored using the CIM data model. In the CIM model, information about objects is stored in CIM classes and CIM instances. CIM instances can contain properties, which have a name, data type, and value. Writing QueriesWBEM 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 namespace. The following example shows a search for all instances of the Solaris_DiskDrive class that have a particular value for the Storage_Capacity property:
WQL Key WordsThe 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
SELECT StatementYou 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:
The following table shows examples of using arguments in the SELECT clause to refine a search. Table 5-3 Sample SELECT Statements
FROM ClauseThe 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. WHERE ClauseThe 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:
The conditional_expression in the WHERE clause takes the following form:
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:
Valid WHERE clauses follow these rules:
| ||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||