Adding your favorite SQL queries to Mumbai

There is a pretty raw way to add your own SQL queries to Mumbai. Since there is no way yet to configure it through a GUI dialog, here’s how to hack it in manually:

  1. Create an *.sql file in the config subdirectory that holds your SQL query (no trailing semicolon). As an example, let’s replicate the sessions view that already exists in Mumbai. We create a sessions.sql file with the line:

    SELECT * FROM V$SESSION

  2. Create a file commands.ini in the config subdirectory, open it in a text editor and create an entry in this file for your SQL statement. For our example this might look like this:

    [sessions]
    Caption=Sessions
    Command=sessions.sql
    ImageIndex=-1
    SortBy=SID,SERIAL#
    SortOrder=ASC,DESC
    SIDColumn=SID
    SERIALCOLUMN=SERIAL#
    SQLIDCOLUMN=SQL_ID
    SQLCHILDNUMBERCOLUMN=SQL_CHILD_NUMBER
    PADDRCOLUMN=PADDR 

    Here is the same entry with explanations:

    [sessions]  -> Any unique identifier.
    Caption=Sessions -> The caption for the menu item in Mumbai.
    Command=sessions.sql -> The filename where the SQL statement is stored.
    ImageIndex=-1 -> The index of the image to be used for the menu item.
    SortBy=SID,SERIAL# -> Columns to sort by, separated by comma.
    SortOrder=ASC,DESC -> Sort order for these columns.
    SIDColumn=SID ->The column name which holds a SID.
    SERIALCOLUMN=SERIAL# ->The column name which holds a SERIAL#.
    SQLIDCOLUMN=SQL_ID ->The column name which holds a SQL_ID.
    SQLCHILDNUMBERCOLUMN=SQL_CHILD_NUMBER ->The column name which holds an SQL child number.
    PADDRCOLUMN=PADDR ->The column name which holds a process address.

  3. What you end up when you (re)start Mumbai is an entry for your SQL command on
    the Ad-hoc>Custom button. 

    When you click this button, you will see the result of your query:

    Notice how the context menu show functionality based on the additional information you gave about the meaning of specific columns like SID, SERIAL#, etc.. Currently only the column identifiers shown in the example entry above are recognized.

This entry was posted in Mumbai. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s