Running a command from Scratchpad


Use the following procedure to run one or more commands directly from the Scratchpad perspective. If Scratchpad is displaying multiple commands, you can run all of them, or select and run a single command.

To run a command

  1. Enter the command or commands into Scratchpad.The source can be either:
    • A command that you pasted or typed into Scratchpad and then edited

      Important

      For SELECT statements that include a CLOB column, you must cast the CLOB column as another type, such as CHAR or VARCHAR.

      The following example displays a cast of the TR.STATEMENT column from CLOB to VARCHAR(32000):

      select cast(TR.STATEMENT as varchar(32000))
      from SYSIBM.SYSTRIGGERS TR
    • A command that you generated from Db2 objects
  2. (BMC.DB2.SPE2210) (Optional) To enable syntax highlighting, select Use syntax highlighting.
  3. (Optional) Enter an alternative SQLID in Current SQLID to set the SQL authorization for the command.
  4. Perform one of the following tasks:
    • To run one command from a group displayed in Scratchpad, select the command and click Run Selected NW_run_selected.png.
    • To run all commands displayed in Scratchpad, click Run NW_run.png.

      Important

      When you run the commands again, any existing output is discarded.

  5. Select the Db2 subsystem on which to run the command. Guidelines are as follows:

    • By default, the last-executed Db2 connection is preselected.
    • Use the menu arrow to select from your list of favorite connections.

    Tip

    Click NW_plug_connect_square_green.png and specify which Db2 connections to include in your list of favorite connections.

    The status bar at the bottom of the screen indicates whether the command runs successfully. The Output tab displays a summary for each command that you ran.

  6. To view results, perform one of the following tasks:

    • To view all results, click View All Result Sets NW_table.png .
    • To view the result set for a specific command, on the Output tab, click the relevant View result set.

    Tip

    If the command failed to run successfully, click View Messages NW_envelope_o_circle.png to see all error messages, or click NW_envelope_o_circle.png on the Output tab to view error messages for a specific command.Also, note that View All Result Sets and View Output Text are enabled only when the Output tab is active.

  7. Save the results as a text file on your local file system:
    1. Click the Output tab, then on the toolbar, click View output text NW_file_text_o.png.
    2. Click Save output text NW_floppy.png.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*