Tkquery - A tool for interactive SQL queries

Synopsis

tkquery [-n dbnode] [-d dbname] [-u user,passwd] [-U xuserKey] [-S sqlmode]

Options

-n
database node (default=local);
-d
database name (default=$SERVERDB);
-u
name and password of user;
-U
name of xuser key.
-S
name of sqlmode (default=adabas).

Introduction

When starting up the application, the user has to give the connect data by filling in the forms of the connect window or using the command line options. If everything is ok, a window called TkQuery is displayed.

The window consists mainly of five parts, which are described here from top to bottom.

Menu bar

By means of the menu bar the user can start all the functionality that tkquery offers. The most important functions can be called also by pressing a function key; for the list of possible keys see chapter Keyboard shortcuts below.

The SQL menu

The top most entries of the SQL menu are for navigate through the history of your sql queries. New clears the SQL window, while Prev and Next cycles through the history. How many queries are stored, can be customized with the resource history (see chapter X-Resources).

Below the separator there are four entries to store and retrieve the queries in the database (beneath the title Stored commands). These functions store the queries in the same system tables and in the same format as xquery (the classic query tool of Adabas D) does; so you can exchange queries between these both tools via the database.

The three entries Open..., Save and Save as... are to store and retrieve the queries from the local file system. They pop up a file selection box, where the user can give a filename.

The bottom most entry in SQL menu is for quitting the program.

The Execute menu

The menu Execute has two groups of entries: At the top there are the commands Execute, Cancel and Continue; at every time at least one of these are disabled. Normally only the Execute command is available. If a SELECT command is currently executed, the Cancel command is activated and will terminate the subsequent fetches. After the cancel of a SELECT statement the Execute command is activated again, and the Continue command to continue fetching more rows is available, too. The bottom most commands Commit now and Rollback now are only enabled, if autocommit (see subsection The Options menu) is switched off. They commit (or rollback) all the sql commands entered since the last call of these commands or since the disabling of autocommit.

The Results menu

The menu Results is for handling of the result window (see section Results window). Here you can clear the result window (Clear) or save its content into a file (Save...). You can activate the protocol, then every query together with its results are appended to the file tkquery.prot.

The Configure... command will pop up a window, containing a check box for every currently selected columnname. Here you can decide, if the values of the column should be displayed in the result. You can also switch off the displaying of a column with a right mouse button click at its column heading.

The output depends on the Style cascade menu of the Options menu. It can be a table in plain text or in HTML or LaTeX format. If the output style is plain, you can call Preview... and a window with the results formatted in plain style will pop up. If the output style is HTML and netscape is running on the same machine and display as tkquery, netscape will display the results.

The Options menu

The Options menu is mostly for customize personal preferences. All options can be configured via resources at startup time of tkquery (see chapter X-Resources).

The DB objects menu

By means of the menu DB objects you can look at all data base objects (tables, columns, views and indexes), that are accessible to you.

After clicking on a menu entry a window pops up, that displays in its left half a tree with all users of the database as well as all their tables, views and indexes, that are visible to you.

You can navigate in the tree by opening and closing subtrees with a click on the + or - signs.

If you click on a table name, the right window will display information about the columns of this table.
If you click on a view name, the right window will display the definition text of this view.
If you click on an index name, the right window will display information about the columns of this index.

The Help menu

The right most Help menu offers you some helpful text (e.g. this one). You can read also an introduction to AdabasTcl, a Tcl extension to connect to the Adabas D serverdb.

With the check button With balloon help you can toggle the helpful labels popping up, if the mouse pointer rests over on of the tool buttons (see section Toolbar buttons).

With the check button Use Netscape you can configure, if Netscape as external browser should be used to display the help texts.

Toolbar buttons

Below the menubar there is a window consisting of buttons for the most important functions of TkQuery.

If the cursor moves over one of these buttons, the status line at the bottom will display a description of the function associated with this button. If the cursor resides more than a half second over the button, a small rectangle containing an even shorter description will pop up (a so called balloon help, which can be disabled in the Help menu, see subsection The Help menu).

User, who dislike the colorful button bar, can disable it in the Option menu (see subsection The Options menu).

Sql window

In this window the user can enter a SQL statement. No special formatting is neccessary (Layout will be ignored). The motif or emacs like control sequences are activ (e.g. C-a for move to beginning of line). The user can start the entered query by a click on the Execute button or by a press of the F5 key.

If the SQL statement is syntactically incorrect, the insert cursor is placed at the point, where the database server detected the error.

The user can scroll the SQL window with the attached scrollbar, can clear it and even switch to the previos or next entered SQL statement.

The sql window can actually contain a little more than blank sql. Before the sql statement there can be a layout specification, which must be framed by LAYOUT and ENDLAYOUT. This layout specifies the content of a window, which will pop up, if the user executes the SQL statement. You can denote entry fields with the & sign, followed by a number; the value of this entry (entered by the user) will be substituted for the corresponding & sign in the sql-statement. A default value for the entry field can be given by a pascal like assignment followed by the value. To let the default value contain blanks, you have to surround it with quotes. An example follows.

    LAYOUT
      Name: &1
      City: &2 := 'Berlin *'
    ENDLAYOUT
    SELECT * FROM address WHERE name = '&1' AND city LIKE '&2'

After the statement you can specify some of the aspects of the output. It must be introduced by the REPORT symbol at the beginning of a line, and can contain NAME, EXCLUDE and INCLUDE statement. An example follows.

    SELECT TIMESTAMP, DATE, TIME FROM dual
    REPORT
      EXCLUDE 1
      NAME    2 'Date' 
      NAME    3 'Time'

You can list more than one sql-statement separated by a line beginning with either a / or a *. This is nice, if you want to update some values and then select the updated values (e.g. for a price increasing).

If there is a selected area in the sql window, only the text of this area is executed. This way you can enter more than one sql statement and can execute them one at a time by selecting only parts of the text.

Results window

The results of an executed select statement are displayed in this window. If there are more results than fit into the window, you can scroll in every direction with the scrollbars, that are attached to the right and bottom of the window (or with Page Up, Page Down, F10 and F11) or the arrows of the toolbar.

You can exclude a column from displaying by clicking its name with the right mouse button. This is a shortcut for the Configure... entry in the Results menu (see subsection The Results menu). There you can reinclude a column, too.

The results can be printed together with the query into a file by means of the function Print... in the menu Results. All queries together with their results are printed in a file called tkquery.prot, if the checkbutton Protocol is activated. The format of the printing, which can be either plain text, latex or html, can be selected in the Options menu.

Also in the Options menu there is the possibility to select a font for the results window.

Status line

In this line there is the message returned from the last executed command or any other help message. To the right there is a label containing the name of the connected user.

Keyboard shortcuts

F1
A window with this help text pops up.
F2
The SQL window and the result window will be cleared.
F3
If currently a query is in work, it will be cancelled and tkquery will fetch no more additional rows. If no query is at work, the program will be terminated.
F5
The query in the SQL window will be executed, and in the case of a SELECT statement, the resulting rows are displayed in the result window.
F6
The next SQL statement will be shown in the SQL window.
F9
The previous SQL statement will be shown in the SQL window.
F10
The result window will scroll a page to the left, if possible.
F11
The result window will scroll a page to the right, if possible.
Movement keys
The input cursor of the SQL window will move in the corresponding direction.
Page Up, Page down
The result window will scroll up (or down) a page, if possible.

Environment variables

SERVERDB
The default Adabas D server name. If not set, the variable DBNAME is inspected also.
ADABASTCL_DIR
The directory to look for the startup scripts.

X-Resources

While starting, the X resource database is read, so that the startup state of some check or radio buttons can be custumized by the user.

The resources can be set via the xrdb command (highest priority) or mentioned in the file $HOME/.Xdefaults. The default values, if no resource assignment can be found, can bee seen in the following excerpt from a resource file.

  *tkquery.fontFamily:   helvetica
  *tkquery.fontSize:     12
  *tkquery.fontStyle:    bold
  *tkquery.autoCommit:   True
  *tkquery.dateFormat:   internal
  *tkquery.outputStyle:  plain
  *tkquery.withProt:     False
  *tkquery.history:      10
  *tkquery.nullValue:
  *tkquery.specialNull:	 ***
  *tkquery.withToolBar:  True
  *tkquery.netscapeHelp: False
  *tkquery.balloonHelp:  True
  *tkquery.errorPopup:   False

Files

$HOME/.XUSER
The xuser file to look for connect parameters.

Bugs

Notes