Cmdlets for IBM Cloud SQL Query

Build 20.0.7654

Capturing Errors and Logging

This section shows how to access the different debug reporting available via PoweShell streams.

Accessing Cmdlet Output From Streams

The cmdlet writes data to several PowerShell streams, the Output stream, Error stream, Verbose stream, and Debug stream. Streams enable you to pass the cmdlet results down the pipeline while writing logs to a file or the console.

Redirecting Errors and Logs

Only success output and errors are returned by default. However, the cmdlets can write to two other streams, the Verbose stream and, for higher levels of verbosity, the Debug stream.

Verbose Stream

The cmdlets write the underlying SQL queries and the execution time to the Verbose stream. To obtain the Verbose stream from the cmdlet, add the "-Verbose" flag.

Select-IBMCloudSQLQuery -Connection $conn -Table "Jobs" -Where "UserId = ''" -Verbose

You can capture the output from this stream by using the redirection operator that corresponds to the stream number. The following line uses the "4>" operator to write cmdlet logs to a file:

Select-IBMCloudSQLQuery -Connection $conn -Table "Jobs" -Where "UserId = ''" -Verbose 4> out.txt

Debug Stream

The Debug stream (stream 5) contains the same information as the Verbose stream as well as more details including the following:

  • Time of execution
  • Low-level interaction with the API of the data source
  • Cache queries
To redirect the Debug stream, use the "5>" redirection operator.
$message = Select-IBMCloudSQLQuery -Connection $conn -Table "Jobs" -Where "UserId = ''" -Debug 5> out.debug.txt

Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 20.0.7654