# CHAPTER 1: Conventions

## 1.1 Command Syntax Notation

The following typographical conventions are used in this manual to aid the reader in locating and identifying information within notations. You should read this section carefully since you will need this information to understand the syntax of commands.

For the sake of brevity, system prompts and Empress prompts are not reproduced for many of the shorter examples. In the case of longer and more complex illustrations, the operating system prompt (represented as %) and the Empress SQL prompt (*) are often displayed to indicate the beginning and end of commands.

Table 1-1: Typographical Conventions - General

Examples | Description
`ALTER table;` | SQL command and 4GL script syntax appear in courier typeface.
`Ready.` `e` | Responses to Empress prompts (to be typed in by the user) are in courier bold.
`MSTERMDB` | Empress system variables are in uppercase and must be typed in uppercase. These variables always start with "MS".
    PAGEWIDTH
    TODAY
| System variables, like keywords, may be typed in any combination of upper- and lowercase. System variables will be written in uppercase in this manual to distinguish them from ordinary variables.
Empress SQL Reference | Italics are used for new terms being introduced or explained and for titles of books, manuals, documents and other publications.
Warning | This indicates the following information is important.

Table 1-2: Typographical Conventions - SQL Statements

Examples | Description
    SELECT
    DISPLAY
| In the syntax definition of the command, words in uppercase are keywords. These are not case-sensitive and may consist of a mixture of uppercase and lowercase when typed into Empress.
    table
    attr
| Items in lowercase italics refer to categories. When typed into Empress, appropriate substitutions of actual names or expressions must be used. For example, `personnel` for `table`. Note that for user defined names, case is significant and must be typed exactly as originally defined.
|`item 1` |`item 2` | | |
| Items stacked between vertical lines "|" are options of which one must be chosen.
`[ ]` | Square brackets are used to indicate that the items enclosed are optional.
`{ }` | Braces may contain more than one item or none at all.
`;` | Characters such as a semicolon must be typed exactly as shown. Optional semicolons are included at the end of each syntax definition, these function as empty statements when included.
SELECT command | When a command is referred to in the text (anywhere other than in the syntax) of the manual, it will usually be written in uppercase.

Table 1-3: Typographical Conventions - Keyboard Keys

<Return> | Keys on your keyboard appear between angled brackets.
<Ctrl+A> | Key chords which require pressing more than one key at a time appear with a "+" separating the keys.

## 1.2 Tables and Attribute

A table can be referred to by a database name followed by a colon (:) followed by the table name (except in a `PRINT` statement). That is, a table can be written as:

`database:table_name`

A script can access tables from several databases. A `SELECT` statement can retrieve data from several databases.

An attribute can be referred to as:

`table.attr_name`

where:

`table` | can include the database name.

Any attributes retrieved via a `SELECT` statement may be used later in the script as though they were variables. Wherever an attribute name appears in a script, its current value will be substituted.

Complex attribute names must be enclosed in quotes and preceded by the `ATTR` keyword, for example, `ATTR 'job no.'`. (The keyword `ATTR` may be omitted from the `WHERE` clause of a `SELECT` statement, but is required in the list of items selected in order to distinguish a complex attribute from an ordinary character string.)

If two attributes with the same name are retrieved from different tables, they must always be qualified by their table names when referred to later, so that Empress Report Writer can distinguish between them.

For example, number in the `customers` table is different from number in the `hours` table. If we have used a `SELECT` statement of the form:

    SELECT customers.number, address, hours.number,
         ATTR hours, job_no
              FROM hours, customers, jobs
              WHERE customers.number = jobs.customer_no
              AND jobs.job_no = hours.number;

we must always specify `customers.number` or `hours.number` later in the report, and not just number, to be sure of getting the correct value.

## 1.3 Variables

Empress Report Writer supports variables which may hold character or numeric values, and which may be used and manipulated in a number of ways. Variable names may be of any length, and all characters in a variable name are significant. Names may include periods, underscores, or colons, but may not include spaces, tabs, or non-printing characters. Keywords may not be used as variable names.

Variables may be `PARAMETER`s or defined in `LET` statements. A variable is created when it is first mentioned.

For example, the statement:

    LET title = "EMPLOYEES OF UNIVERSAL AUTOMOTIVE" CONCAT
         "SERVICES, APRIL 1992";

assigns the character string "EMPLOYEES OF UNIVERSAL AUTOMOTIVE SERVICES, APRIL 1992'' to a variable named `title`. If this variable did not previously exist, it is created. If it did already exist, its previous value is replaced. Wherever `title` appears later in the report, the character string "EMPLOYEES OF UNIVERSAL AUTOMOTIVE SERVICES, APRIL 1992'' will be substituted for it.

As another example, the statement:

`LET nextpage = PAGENUMBER + 1;`

assigns a value one greater than the current page number to a variable named `nextpage`.

If a variable is used in a `SELECT` statement the prefix `var`. must be placed before the variable name in order for its value to be substituted correctly. These variable names also cannot contain underscores.

If the variable `employee` has the current value `Jones`, then to select all Jones' records from the `loans` table, the following would be used:

`SELECT FROM loans WHERE name = 'var.employee';`

Note

The quotes are used because the substituted value will be a character string; a date, decimal or float variable does not need quotes.

`var` must be in lowercase.

## 1.4 Reserved Keywords

Empress Report Writer has a number of keywords and system variable names which may not be used as ordinary variable names. For a complete list of all reserved keywords, please refer to our Reserved Keywords document.

Any attributes which have the same name as a keyword must be treated as complex; it must be enclosed in quotes and preceded by the keyword `ATTR`.

## 1.5 Null Values

The keyword `NULL` can be used in comparisons with attribute values to test whether or not an attribute is null. For example:

    IF phone = NULL
        THEN
        PRINT "No current phone number", NEWLINE;
    END;

Printing of nulls is controlled by the Empress system variable `MSMWNULLOK`. If this variable is set to anything, all null values will be printed as a blank field of the specified width. The variable `MSMWNULLOK` is set by default, so nulls are printed as blanks by default.

If the variable `MSMWNULLOK` is unset, an error message is printed when Empress Report Writer tries to print a NULL.

Refer to the Empress SQL: User's Guide manual for instructions on setting Empress variables.

## 1.6 Character Strings

Character strings are enclosed in single or double quotes, may contain any ASCII character except `NULL (0)`, and are printed out exactly as they appear in the `PRINT` statement.

Backslashes ( \) have no special meaning, and are not used for quoting other characters. If the character string includes a quote of the same type as the delimiting quotes, this included quote must be doubled (that is, printed twice). Hence, if double quotes are used as the string delimiters, a double quote actually contained in the string must be written as "", and if single quotes are the delimiters, an included single quote must be written as ''.

Empress Report Writer character strings do not recognize the C programming language conventions for specifying new lines, tabs, backspaces, etc. Thus, "`\n`'' will print as the two characters "`\`'' and "`n`'', not as a new line; similarly, "`\b`'' is "`\`'' and "`b`'', not a backspace.

## 1.7 Comments

In an Empress Report Writer script, any text between "`/*`'' and "`*/`'' is considered a comment and ignored. A single comment may span several lines.