Previous Next Table of Contents

4. Using sqlscreens

The following is organized more like a reference manual, there is little tutorial material. You may want to look at the sample scripts to get a quick idea.

4.1 Environment variables

The SQLDBTYPE environment variable decides what database code is going to be used. It has two possible values:

The default if the variable is not set is to use MYSQL. Don't depend on it.

This variable can be set inside the script, before the first call to sqlscreen. (It is set to MYSQL inside the sample scripts). Of course, the value of this variable must be consistent with what extensions are available to the TCL interpreter (See installation).

The SQLSCLOG environment variable can be set to the name of a file where Sqlscreens will log the SQL statements it executes. The default is to log to stdout.

The SQLSCHOST, SQLSCUSER, and SQLSCPASSWORD variables can be used to set the connection parameters. These are only used by the sample scripts, not the core package.

MYSQL_TCP_PORT should be used if you need to change the default MySQL connection port.

4.2 Buttons

Each screen has a set of buttons to perform the following operations:

Query

starts a SELECT. The WHERE clause is built with the values currently shown on the screen and the nodisplay fields).

Next

fetches the next record in the current query

Rewind

gets back to the first record in the current query. This has different effects depending on the database: in INFORMIX this actually reruns the query so that changes in the database will be visible. With MySQL, this just rewinds the local result buffer.

Reset

clears all visible and hidden fields in the screen.

Add

inserts the current values. There is special handling for auto_increment fields, see SQL generation

Update

updates the row according to the current values (how the where clause is built is described later, see updateindex and Sql generation ).

Delete

deletes the row(s) selected by the current values. It will prompt for confirmation if more than one row would be affected.

The Update and Add buttons may not exist on all screens (some screens may be set up only for querying).

Delete is not created by default (See allowdelete ).

The SQL generation section describes how the SQL statements are generated for the different actions.

4.3 Keyboard shortcuts

Often, when doing data entry, it is inconvenient to have to reach for the mouse to perform an action. A set of keyboard shortcuts is provided to make things smoother:

<TAB>

goes to the next field in the screen.

<CR>

in any field will start a SELECT.

<ESC>n

will fetch the next row.

<ESC>r

will rewind the query.

<ESC>a

will start an INSERT.

<ESC>u

will start an UPDATE.

<ESC>w

will reset the current screen (clear all fields).

The Update and Add shortcuts will have no effects in query only screens. There is no Delete shortcut.

4.4 Special characters in fields

The '<' and '>' characters will be interpreted when entered as the first character in a non-string field. Actually, if such a field begins with '<', '>', or '=', whatever is entered in it will be included in the WHERE clause when querying. For example:

If you enter ">10" in a field named "quantity", a "quantity > 10" condition will be inserted in the WHERE clause. You could also enter ">10 and quantity < 20", or whatever condition you need. (See also the paragraph about SQL generation ).


Previous Next Table of Contents