headlines
TRUE and FALSE
PQL recognizes TRUE and
FALSE as reserved words
that operate in the same way as in SQL, by adding a true or false condition to
the clause in which they are used. You can use them to provide a condition to
an otherwise conditionless node, to avoid Merge Rule 1.
Wherever you can use an expression that has a strictly Boolean result (true or false),
you can also use the terms TRUE or FALSE.
And since Boolean is a PQL type, you can also use TRUE or
FALSE in an assignment or a test. For example, TRUE and
FALSE can be used in the following situations:
MERGE into / values { foo => true }
SELECT .. FROM .. WHERE shared = true order by 1
TRUE
When used with the MERGE
statement, as in the following example, TRUE provides a
condition for a node that is otherwise conditionless, and thus avoids
Merge Rule 1, which dictates that
if the server finds no conditions on a node, it replaces all existing
nodes with that name:
MERGE INTO / values {
network [TRUE] => {
device[interface/mac_address = '00:00' or
interface/ip_address = '1.2.3.4'] => {
interface => {
name => 'eth0',
mac_address => '00:B1:B2:B3:B4:B5',
ip_address => '10.10.10.40'
}
}
}
}
Since the top-level network node normally does not have any conditions, we
need an exception for this node, or the MERGE statement
will follow Rule 1 and replace the entire tree every time
we run a MERGE statement. The condition of [TRUE] provides that exception.
This statement updates the network tree, rather than replacing it, because
the use of [TRUE] provides an exception from Merge
Rule 1. This particular example is explained in more detail on the
Merge page.
FALSE
When used with the MERGE
statement, as in the following example, FALSE provides a way
to force Merge Rule 2 and ensure new node
creation. For example, you can add a [FALSE] condition to log messages so
that Paglo adds new log nodes instead of updating existing ones:
MERGE INTO / values {
log [FALSE] => {
message => 'Service started',
timestamp => '1/2/07'
}
}
This statement creates a new log, rather than updating an existing log:
row:
*:
log:
timestamp: 1/2/07
message: Service started
For more details about this particular example, see Example of Merge Rule 2.
Example 1: Using TRUE in the predicate
In this example, TRUE is used in the WHERE
clause to limit the query to find shared printers only. To broaden the
query to include information about printers that are not shared, remove
the entire WHERE clause.
This query gathers information about shared printers for which Paglo has WMI information, which helps tracks workload per printer, inventory, and troublehooting.
MERGE INTO / VALUES {
apps[true] => {
com[true] => {
paglo[true] => {
crawlers[true] => {
crawler[guid = '00132034F4AC'] => {
plugins[true] => {
plugin[name = 'snmp_interface_statistics'] => {
enabled[true] => 'true'
}
}
}
}
}
}
}
}
If you run this MERGE statement in the Sandbox, the result looks like this:
row
*
apps
com
paglo
crawlers
crawler
plugins
plugin
enabled: true
Example 2: Using TRUE in the predicate
In this example, TRUE is used in the WHERE
clause to limit the query to find shared printers only. To broaden the
query to include information about printers that are not shared, remove
the entire WHERE clause.
This query gathers information about shared printers for which Paglo has WMI information, which helps tracks workload per printer, inventory, and troublehooting.
SELECT systemname as "Printer Host",
name as "Share Name",
location as "Location",
default as "Default",
portname as "Printer Port",
drivername as "Driver",
published as "Published",
printerstatus as "Status",
local as "Local Printer",
docompletefirst as "Print Spooled First",
capabilitydescriptions as "Capabilities",
horizontalresolution as "Hor. Resolution",
verticalresolution as "Vert. Resolution",
shared as "Shared",
printprocessor as "Print Processor"
FROM /network/device/wmi/win32_printer
WHERE shared = 'true' order by 1
Depending on the network, the results of this query will look similar to these:
row Printer Host AMSTERDAM Share Name DYMO LabelWriter 320 Location Default Printer Port USB888 Driver DYMO LabelWriter 320 Published true Status 3 Idle Local Printer true Print Spooled First true Capabilities Copies, Color, Collate Hor. Resolution 300 Pixels per Inch Vert. Resolution 300 Pixels per Inch Shared true Print Processor WinPrint row Printer Host OAXACA Share Name printer-copier Location Copy Room Default Printer Port IP_10.10.10.10 Driver LANIER 5627 PCL 6 Published true Status 3 Idle Local Printer true Print Spooled First true Capabilities Copies, Color, Duplex, Collate Hor. Resolution 600 Pixels per Inch Vert. Resolution 600 Pixels per Inch Shared true Print Processor WinPrint . . .
Example 3: User environment variables
This example uses a search template to provide a list of hosts to choose from. Run the query, select a host, and the results display the variables for that host.
As in the previous example, this example includes TRUE in the WHERE
clause to limit the query.
SELECT caption as "Variable",
username as "User",
variablevalue as "Environment Value"
FROM /network/device/wmi/win32_environment
WHERE ../win32_operatingsystem/csname =
'[[1param|Windows Hosts|select csname
from /network/device/wmi/win32_operatingsystem
where csname is not null]]'
AND systemvariable != 'true'
Depending on the network, the results of this query will look similar to this:
row Variable: NT AUTHORITY\SYSTEM\TEMP User: NT AUTHORITY\SYSTEM Environment Value: %USERPROFILE%\Local Settings\Temp row Variable: NT AUTHORITY\SYSTEM\TMP User: NT AUTHORITY\SYSTEM Environment Value: %USERPROFILE%\Local Settings\Temp row Variable: NT AUTHORITY\LOCAL SERVICE\TEMP User: NT AUTHORITY\LOCAL SERVICE Environment Value: %USERPROFILE%\Local Settings\Temp . . .
If you change the != 'true' to = 'true',
the results of this query will look similar to this:
row Variable:\APR_ICONV_PATH User: Environment Value: C:\Program Files\Subversion\iconv row Variable: \ClusterLog User: Environment Value: C:\WINDOWS\Cluster\cluster.log row Variable: \ComSpec User: Environment Value: %SystemRoot%\system32\cmd.exe . . .

