Informix SQL 73
Informix SQL 73
Reference Manual
Version 7.3
January 2002
Part No. 000-5471A
Note:
Before using this information and the product it supports, read the information in the appendix
entitled “Notices.”
This document contains proprietary information of IBM. It is provided under a license agreement and is
protected by copyright law. The information contained in this publication does not include any product
warranties, and any statements provided in this manual should not be interpreted as such.
When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information
in any way it believes appropriate without incurring any obligation to you.
© Copyright International Business Machines Corporation 1996, 2002. All rights reserved.
US Government User Restricted Rights—Use, duplication or disclosure restricted by GSA ADP Schedule
Contract with IBM Corp.
Table of Contents
Introduction
In This Introduction . . . . . . . . . . . . . . . . . 3
About This Manual . . . . . . . . . . . . . . . . . . 3
Organization of This Manual . . . . . . . . . . . . . 3
Types of Readers . . . . . . . . . . . . . . . . . 5
Software Dependencies . . . . . . . . . . . . . . . 5
Assumptions About Your Locale. . . . . . . . . . . . 5
Demonstration Database and Examples . . . . . . . . . 6
Documentation Conventions . . . . . . . . . . . . . . 6
Typographical Conventions . . . . . . . . . . . . . 7
Icon Conventions . . . . . . . . . . . . . . . . . 7
Additional Documentation . . . . . . . . . . . . . . . 8
Syntax Conventions . . . . . . . . . . . . . . . . 9
Documentation Included with INFORMIX-SQL . . . . . . . . 13
On-Line Manuals . . . . . . . . . . . . . . . . . 14
Useful On-Line Files . . . . . . . . . . . . . . . . 14
On-Line Help . . . . . . . . . . . . . . . . . . 14
On-Line Error Messages. . . . . . . . . . . . . . . 14
Related Reading . . . . . . . . . . . . . . . . . 15
Informix Welcomes Your Comments . . . . . . . . . . . . 16
Table of Contents v
Chapter 3 The PERFORM Screen Transaction Processor
In This Chapter . . . . . . . . . . . . . . . . . . . 3-3
Running PERFORM . . . . . . . . . . . . . . . . . 3-3
Accessing PERFORM from the Main Menu . . . . . . . 3-4
The PERFORM Screen . . . . . . . . . . . . . . . . 3-6
The Information Lines . . . . . . . . . . . . . . . 3-6
The Screen Form . . . . . . . . . . . . . . . . . 3-8
Status Lines . . . . . . . . . . . . . . . . . . 3-9
Running Operating-System Commands from PERFORM . . . 3-10
Entering Data . . . . . . . . . . . . . . . . . . 3-10
Data Types . . . . . . . . . . . . . . . . . . . 3-10
Special Functions . . . . . . . . . . . . . . . . 3-13
Positioning the Cursor . . . . . . . . . . . . . . . 3-14
Field Editing . . . . . . . . . . . . . . . . . . 3-14
Using the Multiline Editor . . . . . . . . . . . . . 3-16
Display Field Order . . . . . . . . . . . . . . . . 3-17
Data Checking . . . . . . . . . . . . . . . . . . . 3-18
User Access Privileges . . . . . . . . . . . . . . . 3-19
The Current List . . . . . . . . . . . . . . . . . . 3-20
Menu Options . . . . . . . . . . . . . . . . . . . 3-20
ADD . . . . . . . . . . . . . . . . . . . . . 3-21
CURRENT . . . . . . . . . . . . . . . . . . . 3-23
DETAIL . . . . . . . . . . . . . . . . . . . . 3-24
EXIT . . . . . . . . . . . . . . . . . . . . . 3-26
MASTER . . . . . . . . . . . . . . . . . . . 3-27
NEXT . . . . . . . . . . . . . . . . . . . . 3-28
OUTPUT . . . . . . . . . . . . . . . . . . . 3-29
PREVIOUS . . . . . . . . . . . . . . . . . . . 3-33
QUERY . . . . . . . . . . . . . . . . . . . . 3-34
REMOVE . . . . . . . . . . . . . . . . . . . 3-38
SCREEN . . . . . . . . . . . . . . . . . . . 3-39
TABLE . . . . . . . . . . . . . . . . . . . . 3-40
UPDATE . . . . . . . . . . . . . . . . . . . 3-41
VIEW . . . . . . . . . . . . . . . . . . . . 3-42
Chapter 5 User-Menu
In This Chapter . . . . . . . . . . . . . . . . . . . 5-3
Accessing a Menu . . . . . . . . . . . . . . . . . . 5-4
Using a Menu Within INFORMIX-SQL . . . . . . . . . 5-4
Designing a Menu . . . . . . . . . . . . . . . . . 5-6
Creating a Menu . . . . . . . . . . . . . . . . . . 5-8
Accessing PERFORM with the menuform Form . . . . . . 5-8
Entering Menu Data . . . . . . . . . . . . . . . 5-10
Steps for Entering Your Own Data . . . . . . . . . . 5-14
Modifying a Menu . . . . . . . . . . . . . . . . . 5-16
Table of Contents ix
Appendix D Modifying termcap and terminfo
Appendix H Notices
Index
Introduction
In This Introduction . . . . . . . . . . . . . . . . . . 3
About This Manual . . . . . . . . . . . . . . . . . . . 3
Organization of This Manual . . . . . . . . . . . . . . 3
Types of Readers . . . . . . . . . . . . . . . . . . 5
Software Dependencies . . . . . . . . . . . . . . . . 5
Assumptions About Your Locale . . . . . . . . . . . . . 5
Demonstration Database and Examples . . . . . . . . . . 6
Documentation Conventions . . . . . . . . . . . . . . . 6
Typographical Conventions . . . . . . . . . . . . . . 7
Icon Conventions . . . . . . . . . . . . . . . . . . 7
Feature, Product, and Platform Icons . . . . . . . . . . 8
Additional Documentation . . . . . . . . . . . . . . . . 8
Syntax Conventions . . . . . . . . . . . . . . . . . 9
Elements That Can Appear on the Path . . . . . . . . . 9
How to Read a Syntax Diagram . . . . . . . . . . . . 11
Documentation Included with INFORMIX-SQL . . . . . . . . . 13
On-Line Manuals . . . . . . . . . . . . . . . . . . 14
Useful On-Line Files . . . . . . . . . . . . . . . . . 14
On-Line Help . . . . . . . . . . . . . . . . . . . 14
On-Line Error Messages. . . . . . . . . . . . . . . . 14
Related Reading . . . . . . . . . . . . . . . . . . 15
Introduction 3
Organization of This Manual
Types of Readers
This manual is written for all INFORMIX-SQL developers. You do not need
database management experience or familiarity with relational database
concepts to use this manual. A knowledge of SQL (Structured Query
Language), however, and experience using a high-level programming
language would be useful.
Software Dependencies
This manual is written with the assumption that you are using an Informix
database server, Version 7.x or later.
The examples in this manual are written with the assumption that you are
using the default locale, en_us.8859-1. This locale supports U.S. English
format conventions for dates, times, and currency. In addition, this locale
supports the ISO 8859-1 code set, which includes the ASCII code set plus
many 8-bit characters such as é, è, and ñ.
If you plan to use non-ASCII characters in your data or your SQL identifiers,
or if you want to conform to the nondefault collation rules of character data,
you need to specify the appropriate nondefault locale.
Introduction 5
Demonstration Database and Examples
Many (but not all) of the examples in the INFORMIX-SQL documentation set
are based on the stores7 database. This database is described in detail in the
Informix Guide to SQL: Reference. The examples are installed with your
software in the $INFORMIXDIR/demo/sql directory. For U.S. English, go to
the en_us/0333 subdirectory; for other languages, go to the appropriate
subdirectory under the fgl directory.
Documentation Conventions
This section describes the conventions that this manual uses. These
conventions make it easier to gather information from this and other volumes
in the documentation set. The following conventions are discussed:
■ Typographical conventions
■ Icon conventions
■ Example-code conventions
■ Syntax conventions
Typographical Conventions
This manual uses the following conventions to introduce new terms,
illustrate screen displays, describe command syntax, and so forth.
Convention Meaning
italics Within text, new terms and emphasized words appear in italics.
italics Within syntax diagrams and code examples, identifiers or values
italics that you are to specify appear in italics.
monospace Information that the product displays and information that you
monospace enter appear in a monospace typeface.
Icon Conventions
Throughout the documentation, you will find text that is identified by several
different types of icons. This section describes these icons.
Introduction 7
Additional Documentation
Icon Description
GLS
Identifies information that relates to the Informix Global
Language Support (GLS) feature
IDS
Identifies information or syntax that is specific to Informix
Dynamic Server and its editions
SE
Identifies information or syntax that is specific to
INFORMIX-SE
These icons can apply to a row in a table, one or more paragraphs, or an entire
section. A ♦ symbol indicates the end of the feature-specific, product-
specific, or platform-specific information.
Additional Documentation
For additional information, you might want to refer to the following types of
documentation:
Syntax Conventions
This section describes conventions for syntax diagrams. Each diagram
displays the sequences of required and optional keywords, terms, and
symbols that are valid in a given statement or segment, as Figure 1 shows.
Figure 1
Example of a Simple Syntax Diagram
Each syntax diagram begins at the upper-left corner and ends at the upper-
right corner with a vertical terminator. Between these points, any path that
does not stop or reverse direction describes a possible form of the statement.
(For a few diagrams, however, notes in the text identify path segments that
are mutually exclusive.)
Element Description
Introduction 9
Syntax Conventions
Element Description
Element Description
WARNING
, ,
BY NAME variable
The “Case III” label above the diagram implies that this statement can have at
least two other syntax patterns. To use this diagram to construct a statement,
start at the top left with the keyword DISPLAY. Then follow the diagram to the
right, proceeding through the options that you want.
Introduction 11
Syntax Conventions
Manual Description
INFORMIX-SQL User Introduces INFORMIX-SQL and provides the context needed to understand
Guide the other manuals in the documentation set. You do not need database
management experience or familiarity with basic database management
concepts to use this manual. It includes general information about database
systems and leads you through the steps necessary to create a database, enter
and access database information, and produce printed reports.
Informix Guide to SQL: Provides a tutorial on SQL as it is implemented by Informix products, and
Tutorial describes the fundamental ideas and terminology that are used when planning
and implementing a relational database. It also describes how to retrieve infor-
mation from a database, and how to modify a database.
Informix Guide to SQL: Provides full information on the structure and contents of the demonstration
Reference database that is provided with INFORMIX-SQL. It includes details of the
Informix system catalog tables, describes Informix and common environment
variables that should be set, and describes the column data types that are
supported by Informix database engines. It also provides a detailed description
of all of the SQL statements that Informix products support.
Informix Guide to SQL: Contains syntax diagrams for all of the SQL statements and statement
Syntax segments that are supported by the 7.3 database server.
Informix Guide to GLS Provides full information about using Global Language Support features.
Functionality
Informix Error Messages Provides error messages organized by error number. When an error occurs you
can look it up by number and learn its cause and solution.
Introduction 13
On-Line Manuals
On-Line Manuals
The Informix Answers OnLine CD allows you to print chapters or entire
books and perform full-text searches for information in specific books or
throughout the documentation set. You can install the documentation or
access it directly from the CD. For information about how to install, read, and
print on-line manuals, see the installation insert that accompanies Answers
OnLine. You can also access Answers OnLine on the Web at the following
URL: [Link]/answers.
On-Line Help
INFORMIX-SQL provides on-line Help; invoke Help by pressing CONTROL-W.
finderr msg_num
For example, to display the -359 error message, you can enter either of the
following:
finderr -359
or, equivalently:
finderr 359
A few messages have positive numbers. These messages are used solely
within the application tools. In the unlikely event that you want to display
them, you must precede the message number with the + sign.
Related Reading
The following Informix database server publications provide additional
information about the topics that this manual discusses:
Introduction 15
Informix Welcomes Your Comments
■ The name and version of the manual that you are using
■ Any comments that you have about the manual
■ Your name, address, and phone number
Important: The doc alias is monitored only by the Informix departments that create
and maintain manuals and on-line documentation files. It is not an appropriate
channel for technical support issues, sales inquiries, or questions about the avail-
ability of Informix products.
Product Overview
INFORMIX-SQL is a computer-based record-keeping system. As a database
management system, INFORMIX-SQL consists of useful programs or modules
that perform data management tasks. INFORMIX-SQL can substantially
reduce the amount of time required to organize, store, and retrieve infor-
mation. It can summarize, group, and format information in a variety of
helpful ways. With INFORMIX-SQL, you can perform these database
management tasks:
Accessing INFORMIX-SQL
To begin working with INFORMIX-SQL, enter isql at the operating-system
prompt. At this point, INFORMIX-SQL displays the Main menu.
Menu Screens
The top line of a menu screen lists your options. One option is always
highlighted. The second line gives a brief description of the highlighted
option. Each time you press the SPACEBAR, the highlight moves to the next
option and the description changes. You can also use the [ → ] and [ ← ] keys
to move the highlight. The fourth line displays the name of the current
database and the following message:
Press CONTROL-W for Help
Selecting Options
You can normally select menu options in two ways:
■ Use the SPACEBAR to move the highlight over the option you want
to choose and press RETURN.
■ Type the first letter of the option you want to select. Case is not
important—you can type t or T to select the Table option.
INFORMIX-SQL displays the screen for the menu option you have selected.
Text-Entry Screens
The text-entry screen is the second kind of screen. It requires that you enter
text instead of choosing a menu option. The top line of the screen displays the
screen name, followed by double angle (>>) brackets. The second line gives
directions.
The RUN FORM screen is an example of a text-entry screen. Some of the items
it includes follow.
customer
orderform
sample
Entering Text
Whatever you type appears after the double angle brackets at the top of the
screen. Press the RETURN key when you are finished typing. Some screens,
like the RUN FORM screen, give you the option of selecting an item from a list
on the lower part of the screen instead of typing your selection. Use the
Arrow keys to position the highlight over the item you want, and then press
RETURN. INFORMIX-SQL displays the next screen.
Figure 1-1 on page 1-8 is a map of the INFORMIX-SQL menu hierarchy. This
figure illustrates the options on each of the submenus available from the
Main menu.
Figure 1-1
INFORMIX-SQL Menu Hierarchy
Form
Form Form
Report Form
Query-language Form
User-menu Form
Database Form
Table
Menu Options
Query-
Function Form Report Language User-menu Database Table
Create it
Default Generate Generate New Create Create
Custom New New Use-editor
DATABASE
Use the Database option to create a new database, make an existing database
current, or drop an existing database (see Figure 1-3).
Figure 1-3
DATABASE Menu
Menu Options
The DATABASE menu displays four options:
Create creates a new database and makes that database the current
database.
Drop removes a database from the system.
Usage
■ When you create a database with the Create option, that database
becomes the current database.
■ When you use the Select option, you can type the name of an existing
database rather than highlight one of the database names listed on
your screen. If you do so, you must enter the name of a database
located in the current directory or a directory specified in your
DBPATH environment variable. If you enter the name of a nonex-
istent database or a database that INFORMIX-SQL cannot locate,
INFORMIX-SQL displays the following messages:
329:Database not found or no system permission.
2: No such file or directory
■ Be careful when you drop a database; all data in the database is
permanently discarded.
■ The Informix Guide to SQL: Syntax explains the workings of all SQL
database statements that Informix products support.
■ When using the Query-language option, you are not allowed to drop
the current database. You must explicitly close it first with the CLOSE
DATABASE statement. For details about the CLOSE DATABASE
statement, see the Informix Guide to SQL: Syntax.
■ For more information on the DATABASE menu, see the
INFORMIX-SQL User Guide.
EXIT
Use the Exit option to leave the INFORMIX-SQL Main menu and return to the
operating system.
FORM
Use the Form option to run a screen form, create or modify a screen form,
compile a screen form, or drop an existing screen form (see Figure 1-4).
Figure 1-4
FORM Menu
Menu Options
The FORM menu displays the following seven options:
Usage
■ After you edit a form specification file (with the New or Modify
options on the FORM menu), you must compile it. (You cannot use
the form in INFORMIX-SQL until it has been compiled.) Menus
allowing you to compile an edited form are displayed when you
select the New or Modify options. You can also use the Compile
option on the FORM menu to compile a form specification.
INFORMIX-SQL notifies you if errors are in the form specification.
Follow the directions on the screen to correct and recompile the form.
You can save or discard the form after compilation. You can also save
an uncompiled form to work on at a later time or discard it
completely.
■ The INFORMIX-SQL program that compiles a form specification is
called FORMBUILD. See Chapter 2, “The FORMBUILD Transaction
Form Generator,” for information about FORMBUILD.
■ The INFORMIX-SQL program that runs a screen form is called
PERFORM. See Chapter 3, “The PERFORM Screen Transaction
Processor,” for information about PERFORM.
■ For more information on the FORM menu, see the INFORMIX-SQL
User Guide.
QUERY LANGUAGE
Select the Query-language option to use the SQL query language, as
Figure 1-5 shows.
Figure 1-5
SQL menu
SQL: New Run Modify Use-editor Output Choose Save Info Drop Exit
Enter new SQL statements using SQL editor.
Menu Options
The SQL menu displays the following ten options:
New allows you to enter new SQL statements using the SQL editor.
Modify allows you to use the SQL editor to modify the current SQL
statement or statements.
Output routes the output from executing the current SQL statements
to a system file, a printer, or a system pipe.
Choose allows you to select an existing command file that contains
SQL statements and make them your current statements. You
can run or edit the current statements.
Save saves the current SQL statements in a command file. You can
use this command file later by selecting the Choose option on
the SQL menu.
Info allows you to retrieve information about the columns,
indexes, privileges, and status of a table.
Usage
■ If there is no current database, INFORMIX-SQL displays the CHOOSE
DATABASE screen after you select the Query-language option on the
INFORMIX-SQL Main menu.
■ In addition to the tables listed, you can request information about
external tables if you are using Informix Dynamic Server. To specify
an external table, you must enter the expanded table name at the
prompt. For example, the following entry requests information from
the [Link] table in the stores7 database that accesses the
INFORMIX-OnLine system called central:
INFO FOR TABLE >> stores7@central:[Link]
You can also use synonyms in place of the extended table name.
If you select the Status option of the INFO menu, INFORMIX-SQL
displays information on the dbspace that contains the table. The
Status option does not display audit trail information because the
logging facility replaces audit trails.
■ The INFORMIX-SQL User Guide describes how to use the SQL menu
and how to create and run SQL statements.
■ The Informix Guide to SQL: Syntax explains the SQL database state-
ments that Informix products support.
The following sections give some special notes about using SQL statements
with the VARCHAR, TEXT, and BYTE data types.
Using the CREATE TABLE and ALTER TABLE Statements with Blobs
When you use the CREATE TABLE and ALTER TABLE statements, you can
place quotes around blobspace names as shown in the following example:
CREATE TABLE mytab (column1 TEXT IN "blob1")
In this case, the quotes are optional. However, if the name of your blobspace
is table, INFORMIX-SQL requires the quotes to distinguish the blobspace
name with the keyword TABLE. This is demonstrated in the following ALTER
TABLE statement:
In this case, the quotes are required to avoid any ambiguity with the keyword
TABLE.
Using the LOAD and UNLOAD Statements with VARCHARs and Blobs
You can use the LOAD and UNLOAD statements to transfer data between a
table and an operating-system file of ASCII data. This file contains only
printable ASCII and newline characters.
You can use these statements on tables and files that contain the VARCHAR,
TEXT, and BYTE data types. You should read these sections if you are loading
or unloading files that contain VARCHAR or blob data.
For more information on using the LOAD and UNLOAD statements, see the
Informix Guide to SQL: Syntax.
UNLOAD Statement
If you are unloading files that contain VARCHAR, TEXT, or BYTE data types,
note the following information:
LOAD Statement
If you are loading files that contain VARCHAR, TEXT, and BYTE data types,
note the following information:
■ You can give the LOAD statement data in which the character
(including VARCHAR) fields are longer than the column size; the
excess characters are disregarded.
■ You can have leading and trailing blanks in noncharacter fields,
except BYTE fields.
■ In all character fields (including VARCHAR and TEXT), embedded
delimiter and backslash characters are escaped with the backslash.
■ In VARCHAR columns, you must escape newline characters.
■ Data being loaded into a BYTE column must be in ASCII-hexadecimal
form. BYTE columns cannot contain preceding blanks.
REPORT
Use the Report option to run a report, create or modify a report, compile a
report, or drop an existing report from the database, as Figure 1-6 shows.
Figure 1-6
REPORT menu
Menu Options
The REPORT menu displays the following seven options:
Usage
■ After you edit a report specification file (with the New or Modify
options on the REPORT menu), you must compile it. (You cannot use
the report in INFORMIX-SQL until it has been compiled.) Menus
allowing you to compile an edited report are displayed when you
select the New or Modify options. You can also use the Compile
option on the REPORT menu to compile a report specification.
INFORMIX-SQL notifies you if there are errors in the report specifi-
cation. Follow the directions on the screen to correct and recompile
the report. You can save or discard the report after compilation. You
can also save an uncompiled report to work on later or discard the
report completely.
■ The INFORMIX-SQL program that compiles a report specification is
called ACEPREP. The INFORMIX-SQL program that runs a report
specification is called ACEGO. See Chapter 4, “The ACE Report
Writer,” for complete information about these programs.
■ The INFORMIX-SQL User Guide describes how to create and use
reports.
TABLE
Use the Table option to create or modify a table, retrieve information about a
table, or drop a table from the database, as Figure 1-7 shows.
Figure 1-7
TABLE menu
Menu Options
The TABLE menu displays the following five options:
Create allows you to use the interactive schema editor to create a new
table.
Alter allows you to modify a table using the interactive schema editor.
Usage
■ If there is no current database, the CHOOSE DATABASE screen
appears after you select the Table option.
■ Be careful when you drop a table. You lose all the data in the table.
■ The INFORMIX-SQL User Guide describes the use of options on the
TABLE menu.
■ The Informix Guide to SQL: Syntax explains the workings of all SQL
database statements supported by Informix products.
When you are connecting to a database server, the ADD or MODIFY TYPE
menu includes an additional choice of Variable-length as shown in the
following screen.
If you select the VARCHAR data type, you are prompted for the column
length. A VARCHAR column has two lengths: a maximum size and a
minimum space. You can specify these two numbers at the subsequent
prompts, as shown in the following screens.
If you select either TEXT or BYTE, you must indicate where the data is stored.
The BLOBSPACE menu is shown here.
If you choose Table, the column data is stored in the same dbspace as the
other columns. If you choose BLOBSpace-name, you see the following
prompt.
You can enter the name of any existing blobspace at the prompt.
USER MENU
Use the User-menu option to run a user-created menu, create a user-menu, or
modify an existing user-menu as Figure 1-8 shows.
Figure 1-8
USER-MENU menu
Menu Options
The USER-MENU menu displays the following three options:
Usage
■ After you select the User-menu option, the CHOOSE DATABASE
screen appears if there is no current database.
■ Use the Modify option to both create and modify a user-menu.
■ If there is no User-menu for the current database, INFORMIX-SQL
displays a message notifying the user when the Run or Modify
option is selected.
■ See Chapter 5, “User-Menu,” for more information about creating,
modifying, and using a menu.
PROGRAM . . . . . . . . . . . . . . . . . . . . . 2-55
QUERYCLEAR . . . . . . . . . . . . . . . . . . . 2-57
REQUIRED . . . . . . . . . . . . . . . . . . . . 2-58
REVERSE . . . . . . . . . . . . . . . . . . . . . 2-59
RIGHT . . . . . . . . . . . . . . . . . . . . . . 2-60
UPSHIFT . . . . . . . . . . . . . . . . . . . . . 2-61
VERIFY . . . . . . . . . . . . . . . . . . . . . 2-62
WORDWRAP . . . . . . . . . . . . . . . . . . . 2-63
ZEROFILL . . . . . . . . . . . . . . . . . . . . 2-66
Sample Forms
Examples that are in the INFORMIX-SQL User Guide and the INFORMIX-SQL
Reference Manual are based on the following five sample form specifications.
These form specifications illustrate a wide variety of commands available
with PERFORM.
1. Select the Form option on the INFORMIX-SQL Main menu and then
the Generate option on the FORM menu.
2. If there is no current database, the SELECT DATABASE screen
appears. After you select a database, the GENERATE FORM screen
displays. Enter the name you want to assign to the form (for
example, NEWFORM). INFORMIX-SQL asks you for the names of the
tables whose columns you want in your form. The GENERATE FORM
menu allows you to enter up to eight tables. (If you want to include
more than eight tables in your form specification, use the New option
on the FORM menu to create it from scratch.) When you have selected
all the tables you want to include, FORMBUILD creates a default
form specification file. The FORM menu then displays. You can now
use the default screen form with PERFORM.
The default form specification file formats the screen as a list of all
the columns in the tables included in the form. It does not provide
any special instructions to PERFORM about how to display the data,
nor does it include instructions to perform data manipulations.
3. Select the Modify option on the FORM menu, and INFORMIX-SQL
displays the MODIFY FORM screen. Indicate the name of the default
form specification (NEWFORM). If you have not specified an editor
previously in this session or set the DBEDIT environment variable (as
explained in Appendix B, “Setting Environment Variables”),
INFORMIX-SQL asks for the name of your editor. Then
INFORMIX-SQL calls your system editor with the file.
Edit the default form specification file to produce your customized
screen form and associated instructions. Exit from the editor.
4. The MODIFY FORM menu displays. Select the Compile option.
5. If your form specification file compiles correctly, a message to that
effect displays, and FORMBUILD creates a form file with the filename
extension .frm (for example, [Link]). Go to step 7. If your
form specification file contains errors, a message to that effect
displays, and FORMBUILD creates a form file with the filename
extension .err (for example, [Link]). Go to step 6.
6. Select the Correct option from the COMPILE FORM menu.
INFORMIX-SQL calls your system editor with the form specification
file marked with the compilation errors. When you correct your
errors, you need not delete the error messages. INFORMIX-SQL does
that for you. Repeat step 4.
7. When the compilation is successful, select the Save-and-exit option
on the MODIFY FORM menu.
The Generate option is usually a more efficient way to create a custom form
because, if you use the New option, you must enter all form specification
instructions into the file.
To run the compiled form specification directly from the command line, enter
the following command:
sperform newform
You can also create a customized screen form from the operating system
command line using a shortened version of the INFORMIX-SQL Main menu
options. Appendix G, “Accessing Programs from the Operating System,”
discusses this method in detail.
DATABASE section Each form specification file must begin with a DATABASE
section that identifies the database you want to use with
the form.
SCREEN section The SCREEN section appears next and shows the exact layout
of the form as you want it to appear on the screen. If the form
has several screens, this section includes the layout for each
screen, one after another. You can use graphics characters to
enhance the appearance of the screen.
TABLES section Each form specification file must contain a TABLES section
following the SCREEN section. The TABLES section identifies
the tables whose columns appear in the form.
ATTRIBUTES The ATTRIBUTES section describes each field on the form
section including, for example, appearance, acceptable input values,
displayed comments, and default values.
INSTRUCTIONS The INSTRUCTIONS section is optional and specifies master-
section detail relationships, composite joins, alternative field delim-
iters, and control blocks.
Using the END keyword to mark the end of sections in the form specification
file is optional. Some users find it helpful to indicate the close of a section
with END. The forms included with the demonstration database use the END
keyword.
screen
{
--------------------------------------------------------------------------
CUSTOMER INFORMATION:
Customer Number: [c1 ] Telephone: [c10 ]
.
.
.
SHIPPING INFORMATION:
Customer P.O.: [o20 ]
end
tables
customer orders
attributes
c1 = *customer.customer_num
= orders.customer_num;
c10 = phone, picture = "###-###-####x#####";
.
.
.
o20 = po_num;
o21 = ship_date;
o22 = paid_date;
instructions
customer master of orders;
orders master of items;
end
DATABASE Section
The DATABASE section of a form specification file identifies the database with
which the form is designed to work.
DATABASE Section
Use the WITHOUT NULL INPUT option only if you have elected to create and
work with a database that does not have NULL values. For fields that have no
other defaults, this option causes INFORMIX-SQL to display zeros as default
values for number and INTERVAL fields, and blanks for character fields.
The default DATE value is 12/31/1899; the default DATETIME value is 1899-
12-31 23:59:59.99999.
The following DATABASE section is from the sample form specification file at
the end of this chapter:
database
stores7
With Informix Dynamic Server, you can specify the full name of a remote
database in the DATABASE section. List the simple names of the tables in the
TABLES section. For more information, see “TABLES Section” on page 2-21.
SCREEN Section
The SCREEN section of the form specification file describes how the form
appears on the screen when you use it with PERFORM. A form specification
can include multiple SCREEN sections that correspond to multiple page
layouts.
SCREEN
Section
Page Layout
SCREEN { p. 2-14 }
SIZE lines BY columns END
Usage
■ Each page layout is preceded by the SCREEN keyword and is
enclosed in braces ( { } ). A page layout consists of an array of display
fields and textual information, such as titles, field labels, and graphics
characters. Display fields are indicated by brackets ( [ ] ) that define
the field length and by field tags that identify the field.
■ The default SCREEN section is SCREEN SIZE 24 by 80. FORMBUILD
prepares a screen of up to 20 lines (4 lines are reserved for system
use) and up to 80 characters in a line.
■ Use the SIZE keyword to indicate an alternative screen size. If you do
not indicate a larger screen size, and if you include more than 20
screen lines between a pair of braces, FORMBUILD splits the page,
with line 21 at the top of the second page.
■ If you specify a screen size, the size must appear on the first screen.
The size applies to all the screens.
■ You can use command-line syntax to override either or both of the
lines or dimensions of the SCREEN section by specifying:
sformbld -l lines -c cols filename
where lines and cols are defined as in the above syntax diagram, and
filename is the name of the form specification file. FORMBUILD uses
the INFORMIXTERM environment variable to determine whether to
use termcap or terminfo at compile time to set screen characteristics.
If INFORMIXTERM is unset, FORMBUILD uses termcap.
The following example illustrates the use of the SCREEN keyword with
multiple page layouts:
SCREEN SIZE 18 BY 75
{
.
.
.
display fieldspage layout
.
.
.
SCREEN
{
.
.
.
display fieldspage layout
.
.
.
The sample form included at the end of this chapter demonstrates the
SCREEN sections of a multiple-page form.
Page Layout
You indicate where data is to be displayed on the screen by using brackets
( [ ] ) to delimit a field. Each field has an associated field tag that identifies the
field in the ATTRIBUTES and INSTRUCTIONS sections.
Page Layout
|
text [ field-tag ]
Usage
■ Each field must have a field tag. The field tag is from 1 to 50
characters long. The first character must be a letter; the rest of the tag
can include letters, numbers, and underscores (_). The field tag must
be short enough to fit within the brackets. You can use the same field
tag at more than one position in the SCREEN section of the form
specification if you want the same column information to appear in
more than one place.
■ Field tags are not the same as database column names; they are the
associations used in the SCREEN section, the ATTRIBUTES section,
and the INSTRUCTIONS section to tell PERFORM where to display and
store information. The ATTRIBUTES section associates each field tag
with a column in your database or identifies it as a display-only field.
■ FORMBUILD ignores the case of a field tag; a1 and A1 are the same.
■ If you edit and modify the default form specification file or create
one from scratch, you can verify that the character column field
widths match the data type of the corresponding columns by using
the verify (-v) option of FORMBUILD. Enter the following command
in response to the system prompt:
sformbld -v newform
FORMBUILD reports any discrepancies in the file [Link], where
newform is the name of the form specification file that has been
verified.
■ The | bar symbol can be used to denote the close of one field and
the beginning of the next field. In the following example, field-
tag1 identifies the first display field; field-tag2 identifies the
second display field:
text [field-tag1 | field-tag2 ]
When you use the bar symbol to denote the close of one field and the
beginning of the next field, you must include a DELIMITERS
statement in the INSTRUCTIONS section of the form specification.
Use the same symbol as both the left and right delimiters in the
statement.
The screen layout from the sample form specification file follows:
screen
{
================================================================================
================================================================================
================================================================================
================================================================================
}
screen
{
================================================================================
CUSTOMER NUMBER: [c1 ] COMPANY: [c4 ]
ORDER INFORMATION:
Order Number: [o11 ] Order Date: [o12 ]
You can enter command strings to invoke a simple line drawing or graphics
in which standard characters produce special effects on a compiled,
displayed form. The letter p, for example, becomes the upper left corner of a
box while a series of hyphens becomes a solid horizontal rule, as shown in
Figure 2-3.
Figure 2-3
Form Specification Form Specification
and Displayed Form
database STORES7 (Method 1)
screen
{
\gp---------------------------------------------------------q
\g|------------------------\gCUSTOMER\g-----------------------|
\g|\g
\g|\g Cust No [f000] Company [f001 ] \g|
\g|\g \g|
\g|\g Name: [f002 ] [f003 ] \g|
\g|\g \g|
\g|\g Telephone Number: [f004 ] \g|
\g|\g
\g|\g
\g|\g CUSTOMER
\g|\gCust No. [112 ] Company [Runners & Others ]
\g|\g
} Name [Margaret ] [Lawson ]
e
Telephone Number: [415-887-7235 ]
Displayed Form
Character Produces
_ a horizontal-line character
| a vertical-line character
The meanings for these six characters are derived from the gb speci-
fication in the termcap file, or the acsc specification in the terminfo
file. INFORMIX-SQL substitutes the graphics characters specified in
the termcap or terminfo file for these characters when you display
the compiled form.
3. After the form has the desired configuration, use the \g string to
indicate when to begin graphics mode and when to end graphics
mode.
Insert the \g string before the first p, q, d, b, dash, or pipe that repre-
sents a graphics character. To leave graphics mode, insert the string
\g after the p, q, d, b, dash, or pipe. Figure 2-4 shows the commands
that draw a box around text.
Figure 2-4
\gp-----------------------q Drawing a Box
\g|\g \g| Around Text
\g|\g this is text \g|
\g|\g \g|
\g|\g text, 2 \g|
\g|\g \g|
\gb-----------------------d
Specification
this is text
text, 2
Displayed Result
Do not insert the \g strings in original white space on the form. The backslash
should displace the first graphics character in the row and push the
remaining row to the right. Although this distorts the way the form specifi-
cation looks on screen, the actual output will not be distorted.
In your form specification, you can include not only the characters used to
create a box or rectangle, but also other graphics characters. However, the
meaning of a character other than p, q, d, b, dash, and pipe depends on your
terminal.
termcap:
terminfo:
acsc the concatenated, ordered list of ASCII equivalents for the six
graphics characters used to draw the border.
For information about making changes to your termcap and terminfo files,
see Appendix B, “Setting Environment Variables,” or check the manual that
comes with your terminal.
TABLES Section
The third section of the form specification file lists all the tables from which
columns appear in the screen form. You need not display in the screen form
every column of every table listed, but any table contributing data to the form
must be included.
In an ANSI-compliant database, a form must qualify any table name with the
owner. prefix if users other than owner run the form. If you specify an owner
name, you must specify a simple alias for [Link]-name in the TABLES
section to reference the table in other sections of the form specification file.
TABLES
Section
TABLES table-name
Usage
■ You cannot include a temporary table in your table list.
■ You can build a form based on a view as long as the columns that
contribute data to the view belong to only one table. Aggregate data
is not allowed.
■ The number of tables that you can use in a form is machine
dependent. On most UNIX systems, the maximum number of tables
open at one time is 12.
The TABLES section from the sample form specification file at the end of this
chapter is as follows:
tables
customer items stock
orders manufact
Remote Databases
With Informix Dynamic Server, you can specify remote databases, external
tables, and external, distributed tables in forms. You can make a remote
database the current database for use with the form, or you can specify a table
external to the current database in your form.
You can specify the full name of a remote database in the DATABASE section
of the form. List the simple names of the tables in the TABLES section. You can
also use table-name synonyms in the TABLES section as long as they have
been defined for the current database. These synonyms can stand for tables
in the current database or in other databases.
In the ATTRIBUTES section of the form, refer to tables in the current database
with their simple table names. You can also use synonyms in the ATTRIBUTES
section as follows:
ATTRIBUTES
f0 = [Link], .....;
f1 = [Link], ......;
f2 = [Link], .....;
.
.
.
■ External tables
■ Tables within the current database that are qualified by their owner
names
■ Multipart synonyms
For example, if you have the following declaration in your tables section:
timecard_a = otherdb:[Link]
You see the alias rather than the actual table name in error messages. If you
are using PERFORM, you see the alias instead of the table name on the second
line of the screen.
ATTRIBUTES Section
The ATTRIBUTES section describes the behavior and appearance of each field
defined in the SCREEN section. Every field in the SCREEN section must be
described in the ATTRIBUTES section. You use attributes to describe how
PERFORM should display the field, to specify a default value, to limit the
values that can be entered, and to set other parameters, as described in the
“ATTRIBUTES Syntax” on page 2-31.
The order in which the fields are described in the ATTRIBUTES section deter-
mines the default order for the cursor movement on the screen. The order in
which columns are referenced determines the order in which PERFORM
makes tables active (that is, available for data entry).
ATTRIBUTES
Section
=
field-tag = Field Description ;
ATTRIBUTES p. 2-26
Displayonly Field
p. 2-28
Table Order
When a form contains fields that correspond to several database tables,
PERFORM puts the tables in an ordered list. When you use the Table option,
PERFORM changes the active table by selecting the next table in the list.
PERFORM assigns tables in the order in which columns in the tables are refer-
enced in the ATTRIBUTES section. You reference a table whenever you
associate a column from the table with a tag name or another column in a
join.
Field Description
column-
name ;
* table .
,
, attribute-
specification
Usage
■ You can display portions of CHAR-type columns in a field by using
subscripting. For example, the orders table has a ship_instruct
column that is a CHAR-type column of length 40. You can display it
on the screen as two display fields of length 20. If the field tags for
the two fields are inst1 and inst2, respectively, the ATTRIBUTES
section entry is as follows:
inst1 = ship_instruct[1,20];
inst2 = ship_instruct[21,40];
You can also use the WORDWRAP attribute to display long CHAR
fields on multiple lines.
■ If you use an alias in the TABLES section, you must use the alias to
refer to the table in the ATTRIBUTES section.
■ In the ATTRIBUTES and INSTRUCTIONS sections of the form, refer to
external tables in the following way:
ATTRIBUTES
.
.
.
f3 = [Link], .....;
.
.
.
For example, if you have the following declaration in your tables
section:
timecard_a = otherdb:[Link]
part of your ATTRIBUTES section might look like this:
f3 = timecard_a.sickleave
You see the alias rather than the actual table name in error messages.
If you are using PERFORM, you see the alias instead of the table name
on the second line of the screen.
For more information about accessing external tables, see “TABLES
Section” on page 2-21.
Display-Only Fields
Display-only fields are not associated with columns of the database and
appear only on the screen. They receive their values as a result of calculations
or logical decisions based on the values in other fields.
Displayonly Field
■ Do not give a length to type CHAR; the display width determines the
length.
■ If you specify the precision for a DECIMAL or MONEY type, be certain
that the display width can hold the value.
■ When the field does not allow input, you can use only the following
attributes with display-only fields:
DEFAULT DOWNSHIFT
FORMAT QUERYCLEAR
REVERSE RIGHT
UPSHIFT ZEROFILL
The ATTRIBUTES section of the sample form specification file contains the
following two DISPLAYONLY fields:
d1 = displayonly type money;
d2 = displayonly type money;
These fields are used to calculate the shipping charge and total order amount
for each order. This information is not stored in any columns in the database.
Joining Columns
A screen form that contains information from several database tables
normally includes a display field that joins two (or more) database columns
that contain the same information. While it is not required that the join
columns be indexed, it is advisable because cross-table queries do not run as
quickly if the underlying join columns are not indexed.
The database columns you join must be of the same data type. If they are
CHAR columns, they must be the same length. Do not join two SERIAL
columns to each other; join a SERIAL column only to an INTEGER column.
You join columns by equating them to the same field tag in the ATTRIBUTES
section:
field-tag = col1 = col2;
Field-tag o11 joins the order_num column of the orders table with the
order_num column of the items table. (The asterisk placed before the
orders.orders_num column name indicates that this is a special kind of
join—a verify join. Verify joins are explained on page 2-30.)
The placement of attributes determines when they take effect. If you want an
attribute to apply regardless of which table in the join is active, place the
column names on the same line and the attribute after the last column name:
field-tag = col1 = col2, attr;
If you want different attributes to apply for each of the columns in the join,
place the column names on separate lines:
field-tag= col1, attr1;
= col2, attr2;
attr1 is effective when the table that contains col1 is active, and attr2 is
effective when the table that contains column2 is active.
Verify Joins
You can verify that the value you enter into a field that corresponds to a
column in one table already exists in another column (the dominant column)
in another table. You do this through a verify join. You indicate the verify join
by placing an asterisk in front of the dominant column name, as follows:
field-tag = col1 = *col2;
PERFORM prevents entry of any value into field-tag that does not already
occur in col2. (This applies for noncomposite conditions.)
For example, when you assign orders to customers, you want to ensure that
the customer number entered for a store is a valid customer number in the
customer table. The following statement in the ATTRIBUTES section of the
sample form does just this:
c1 = *customer.customer_num
= orders.customer_num;
A third kind of join, described under “LOOKUP” on page 2-48, allows you to
display or verify data from a table that is not active.
ATTRIBUTES Syntax
PERFORM recognizes the following attributes. The syntax for each attribute is
detailed in the following sections.
AUTONEXT
CENTURY
COLOR
COMMENTS
DEFAULT
DOWNSHIFT
FORMAT
INCLUDE
INVISIBLE
LOOKUP
NOENTRY
NOUPDATE
PICTURE
PROGRAM
QUERYCLEAR
REQUIRE
REVERSE
RIGHT
UPSHIFT
VERIFY
WORDWRAP
ZEROFILL
AUTONEXT
Use the AUTONEXT attribute to cause the cursor to advance automatically to
the next field when the current field is full.
AUTONEXT
Usage
■ AUTONEXT is particularly useful for entering text into a CHAR type
database column that is split among two or more display fields with
the use of subscripts.
■ Another use of AUTONEXT is with CHAR fields in which the input
data is of a standard length (for example, the abbreviation for a state
name is always two digits) or when the CHAR field has a length of
one (only one keystroke is required to enter the data and to move to
the next field).
The sample form specification file uses the AUTONEXT attribute to display
the state and zipcode columns from the customer table, as shown:
c8 = state, upshift, autonext;
c9 = zipcode, autonext;
When two characters are entered into the c8 field (and the field is full), the
cursor moves automatically to the beginning of the next field (the c9 field).
When five characters are entered into the c9 field (and the field is full), the
cursor moves automatically to the beginning of the next field.
CENTURY
The CENTURY attribute specifies how to expand abbreviated one- and two-
digit year specifications in a DATE and DATETIME field. Expansion is based on
this setting (and on the year value from the system clock at runtime).
CENTURY = "R"
"C"
"F"
"P"
C or c is used for the past, future, or current year closest to the current
date.
F or f is used for the nearest year in the future to expand the entered
value.
P or p is used for the nearest year in the past to expand the entered
value.
R or r is used to prefix the entered value with the first two digits of the
current year.
Usage
In most releases of INFORMIX-SQL earlier than 7.20, if the user enters only the
two trailing digits of a year for literal DATE or DATETIME values, these are
automatically prefixed with the digits 19. For example, 12/31/02 is always
expanded to 12/31/1902, regardless of when the program is executed.
This legacy behavior is sometimes called the Y2K problem.
CENTURY can specify any of four algorithms to expand abbreviated years
into four-digit year values that end with the same digits (or digit) that the
user entered. CENTURY supports the same settings as the DBCENTURY
environment variable, but with a scope that is restricted to a single field.
Here past, current, and future are all relative to the system clock.
Unlike DBCENTURY, which sets a global rule for expanding abbreviated year
values in DATE and DATETIME fields that do not have the CENTURY attribute,
CENTURY is not case-sensitive. You can substitute lowercase letters (r, c, f, p)
for these uppercase letters. If you specify anything else (for example, a
number), then R is used as the default. If the CENTURY and DBCENTURY
settings are different, then CENTURY takes precedence.
Important: The CENTURY attribute has no effect on DATETIME fields that do not
include YEAR as the first time unit, nor on fields that are not DATE or DATETIME
fields. If an abbreviated year value is entered in a character field or a number field, for
example, then neither CENTURY nor DBCENTURY has any effect.
COLOR
Use COLOR to display field text in one of eight colors, either alone or
combined with one or more of four intensities.
display
COLOR = mode
where
WHERE condition
Usage
The display mode consists of zero attributes or one attribute from the color list,
and zero or more attributes from the intensity list, as follows.
WHITE White
YELLOW Yellow
MAGENTA Magenta
RED Red
CYAN Cyan
GREEN Green
BLUE Blue
BLACK Black
(1 of 2)
BLINK Blinking
UNDERLINE Underlined
The following example illustrates how to specify that field text should be
displayed in red type:
f000 = customer.customer_num, color=red;
GLS The evaluation of MATCHES, LIKE, and BETWEEN expressions that contain
character arguments is dependent on collation settings. Refer to Appendix C,
“Global Language Support,” and the Informix Guide to GLS Functionality.♦
COMMENTS
Use COMMENTS to cause PERFORM to display a message on the Comment
line at the bottom of the screen. The message displays when the cursor moves
to the associated field.
COMMENTS = "message"
Usage
■ The message must appear in quotation marks on a single line of the
form specification file.
■ The Status line is the bottom line of the screen. The Comment line is
just above the Status line.
■ The most common use of the COMMENTS attribute is to give infor-
mation or instructions to the user. This is particularly appropriate
when the field accepts only a limited set of user-specified values.
Related Attribute
INCLUDE
DEFAULT
Use the DEFAULT attribute to assign a default value to a display field.
DEFAULT = value
Usage
■ If you do not use the DEFAULT attribute, display fields default to
blanks.
■ Enclose DATE values and CHAR values that contain spaces or special
characters in quotation marks. Using quotation marks around CHAR
values that contain no spaces or special characters is optional.
■ PERFORM displays the default value whenever the field displays for
data entry in an Add operation.
■ If both the DEFAULT attribute and the REQUIRED attribute are
assigned to the same field, the REQUIRED attribute is ignored.
■ Use the TODAY keyword as the value to assign the current date as the
default value of a DATE field.
■ Use the CURRENT keyword to assign the current date and time as the
default value of a DATETIME field.
■ If you use the WITHOUT NULL INPUT option in the DATABASE
section and you do not use the DEFAULT attribute, then character
fields default to blanks, number and INTERVAL fields default to 0,
and MONEY fields default to $0.00. The default DATE value is
12/31/1899, and the default DATETIME value is 1899-12-31
23:59:59.99999.
■ If you do not use WITHOUT NULL INPUT in the DATABASE section,
all fields default to NULL values unless you use the DEFAULT
attribute.
■ You cannot use DEFAULT with fields of type TEXT or BYTE.
DOWNSHIFT
Assign the DOWNSHIFT attribute to a CHAR field when you want PERFORM
to convert uppercase letters to lowercase letters.
DOWNSHIFT
Usage
Because uppercase and lowercase letters have different ASCII values, storing
character strings in one format or the other can simplify sorting and querying
a database.
GLS The results of conversion between uppercase and lowercase can be tailored
to the national language in use, as defined by GLS settings. Refer to Appendix
C, “Global Language Support,” and the Informix Guide to GLS Functionality. ♦
Related Attribute
UPSHIFT
FORMAT
Use the FORMAT attribute with a DECIMAL, SMALLFLOAT, FLOAT, or DATE
column to control the format of the display.
FORMAT = fstring
Usage
■ For DECIMAL, SMALLFLOAT, or FLOAT data types, fstring consists of
pound signs (#) that represent digits and a decimal point. For
example, ###.## produces up to three places to the left of the
decimal point and exactly two places to the right.
■ If the actual displayed number is shorter than the fstring, PERFORM
right-justifies it and pads the left with blanks.
■ If the fstring is smaller than the display width, FORMBUILD gives a
warning, but the form is usable.
■ If necessary, PERFORM rounds numbers before displaying them.
The following table lists example FORMAT attributes for DATE fields.
Input Result
o22 = paid_date,
format = "mm/dd/yyyy";
GLS The way the format string in the FORMAT attribute is interpreted for numeric
and monetary data can be modified by GLS settings. In the format string, the
period symbol (.) is not a literal character but a placeholder for the decimal
separator specified by environment variables. Likewise, the comma symbol
(,) is a placeholder for the thousands separator specified by environment
variables. The $ symbol is a placeholder for the leading currency symbol. The
@ symbol is a placeholder for the trailing currency symbol. Thus, the format
string $$#,###.## will format the value 1234.56 as £1,234.56 in a British locale
but as f1.234,56 in a French locale. Refer to Appendix C, “Global Language
Support,” and the Informix Guide to GLS Functionality.
The mmm and ddd specifiers in a format string can display language-specific
month name and day name abbreviations on the form. This requires the
installation of message files in a subdirectory of $INFORMIXDIR/msg and
subsequent reference to that subdirectory by way of the environment
variable DBLANG. For example, the ddd specifier in a Spanish locale trans-
lates the day Saturday into the day name abbreviation Sab, which stands for
“Sabado” (the Spanish word for Saturday). ♦
Related Attribute
PICTURE
INCLUDE
Use the INCLUDE attribute to specify acceptable values for a field and to
cause PERFORM to check input before accepting it.
INCLUDE = ( value )
TO value
NULL
Usage
■ When you specify a range of values, the lower value must appear
first.
■ For ranges of character values, PERFORM uses dictionary ordering
with the printable ASCII character set. (See Appendix E, “The ASCII
Character Set,” for an ordered list of the ASCII character set.) In a
number field, the range (5 to 10) is acceptable. In a CHAR field, it is
incorrect. The character string 10 is less than the string 5, since 1
comes before 5 in the ASCII character set.
■ If you include a character string that contains a blank space, a
comma, or any special characters, you must enclose the entire string
in quotation marks. It is advisable to enclose character strings in
quotation marks at all times.
■ Before PERFORM accepts a new row, you must enter an acceptable
value in each display field with the INCLUDE attribute. Use the
keyword NULL to indicate that a NULL value is acceptable. If a field
has both the DEFAULT and INCLUDE attributes, then the DEFAULT
value must appear in the INCLUDE list. Otherwise the form does not
compile.
GLS The results of evaluation of character data in INCLUDE ranges can be affected
by GLS settings. A given character will be contained in an INCLUDE range or
not depending on where it collates relative to the INCLUDE values. Refer to
Appendix C, “Global Language Support,” and the Informix Guide to GLS
Functionality. ♦
Related Attributes
COMMENTS, REQUIRE
INVISIBLE
If a field is defined as INVISIBLE, INFORMIX-SQL does not display the value
assigned to the field or the value the user is entering in the field.
INVISIBLE
Usage
■ If you assign both INVISIBLE and COLOR attributes to a field,
INFORMIX-SQL ignores the COLOR attribute, unless you specify
COLOR=REVERSE. In this case, INFORMIX-SQL displays the field in
reverse video and maintains the invisibility of the field’s contents.
■ If you assign both INVISIBLE and PICTURE attributes to a field,
INFORMIX-SQL does not display the picture pattern.
LOOKUP
Use the LOOKUP attribute to display data from another table while entering
data into or querying the active table. You can also use it to prevent data from
being entered into the active table if the value does not exist in another table.
*
field-tag1 = table2.col1
, field-tag2 = table2.col2
Usage
■ If you use an alias in the TABLES section, you must use the alias to
refer to the table in the ATTRIBUTES section.
■ The optional asterisk placed in front of [Link] tells PERFORM to
accept a value for [Link] only if the same value already exists in
[Link].
■ The optional list of field tags with column names following the
LOOKUP attribute directs PERFORM to display these values
whenever there is a successful join between [Link] and [Link].
You cannot enter values into these fields from the keyboard.
■ If the join columns in a LOOKUP are not indexed, the LOOKUP does
not run as quickly.
An example of the LOOKUP join from the sample form specification file
follows:
i16 = items.manu_code,
lookup m17 = manufact.manu_name
joining *manufact.manu_code;
In this example, the entry of the item manufacturer code number is checked
against the list of manufacturer code numbers in the manufact table. If the
same value is found there, the manufacturer’s name is extracted from the
manufact table and displays in field m17.
NOENTRY
Use the NOENTRY attribute to prevent data entry when a new row is created
during an Add operation.
NOENTRY
Usage
■ The NOENTRY attribute does not prevent you from modifying the
field during an Update operation.
■ The NOENTRY attribute is unnecessary with a SERIAL column.
When the stock table is active, the columns i13 and s14 (corresponding to the
columns stock.stock_num and [Link], respectively) cannot have
values added. (The inclusion of the NOUPDATE attribute prevents data entry
during an Update operation.)
Related Attribute
NOUPDATE
NOUPDATE
Use the NOUPDATE attribute to prevent data entry when a row is modified
during an Update operation.
NOUPDATE
Usage
The NOUPDATE attribute does not prevent you from entering data into the
field during an Add operation.
When the stock table is active, the fields s15 and s16 (corresponding to the
columns stock.unit_price and stock.unit_descr, respectively) cannot receive
values during an Update operation. (The inclusion of the NOENTRY attribute
prevents data entry during an Add operation.)
Related Attribute
NOENTRY
PICTURE
Use the PICTURE attribute to specify the character pattern for data entry to a
non-number field.
PICTURE = "pstring"
Usage
■ pstring is a combination of three special symbols.
Symbol Meaning
A Any letter
# Any digit
X Any character
The following examples are from the sample form specification file:
c10 = phone,
picture = "###-###-####x####";
As another example, if you specify a field for part numbers like this:
f1 = part_no, picture = "AA#####-AA(X)";
LF49367-BB(*)
TG38524-AS(3)
YG67491-ZZ(D)
GLS The PICTURE attribute is not affected by the GLS settings because PICTURE
only formats character information. ♦
Related Attribute
FORMAT
PROGRAM
You can use the PROGRAM attribute with a blob (BYTE or TEXT) column to call
an external program to work with the TEXT or BYTE data. You invoke an
external program by pressing the exclamation key while your cursor is in a
blob field. The external program then takes over control of the screen. When
you exit the external program, the form is restored on your screen.
Usage
If you call the program on an empty field, when you finish working in the
external program and save your work, the data is stored in the blob field. If
you call the program from a field that already contains data, the specified
program works on the data in that field. In either case, Informix Dynamic
Server writes the blob to a temporary file, which is then passed to the external
program. The external program must write its changes back to the temporary
file. You do not need to know the name of the temporary file; the application
development tool keeps track of it. For example, you might use PROGRAM to
call a CAD or graphics program to display a drawing that you have stored.
You can also use PROGRAM to invoke an editor for a TEXT field.
For example, a TEXT field might be tagged with the following line:
f003 = [Link], WORDWRAP, PROGRAM = "edit";
When you display a field with data type TEXT, INFORMIX-SQL displays as
many of the leading characters as will fit in the defined field. When you
display a field with data type BYTE, INFORMIX-SQL displays <BYTE value>.
When you place the cursor in a TEXT field, and you press the exclamation-
mark key in the first character position of a TEXT or BYTE field, the external
program is invoked. This program receives the contents of the field and takes
control of the screen to permit editing or alteration of the field. When the
program is finished, your application regains control of the screen and
continues execution.
You must explicitly define the external program for a BYTE field; the default
editor is not called, and the DBEDIT environment variable is not examined.
Before invoking the program, INFORMIX-SQL copies the BYTE or TEXT field to
a temporary disk file. It then issues a system command composed of the
name that you specify after the PROGRAM keyword followed by the name of
the temporary file.
The name string need not be a single word. You can add additional command
parameters. The program can also be a shell script, so that you can initiate a
whole series of actions.
If you are invoking an external program from PERFORM, the data is stored in
the blob column when you complete the Add or Update. For example:
f010 = contract, PROGRAM = "edit";
QUERYCLEAR
Use the QUERYCLEAR attribute to clear a joining field on the screen when you
enter a Query operation.
QUERYCLEAR
Usage
■ When you enter the Query option, PERFORM normally clears all
fields except joining and display-only fields.
■ QUERYCLEAR does not apply to display-only fields. You must give
explicit instructions in the INSTRUCTIONS section to clear display-
only fields.
Here the items table and the stock table are joined through the stock number.
When the stock table is the active table and a query is made, the stock_num
field is cleared. When items is the active table, however, the stock_num field
is not cleared when a query is made.
REQUIRED
Use the REQUIRED attribute to force data entry into a particular field during
an Add operation.
REQUIRED
Usage
■ The REQUIRED attribute has no effect during a PERFORM Update
operation. You are free to erase values from REQUIRED fields when
you use an Update operation.
■ There is no default value for a REQUIRED field. If you assign both the
REQUIRED attribute and the DEFAULT attribute to the same field, the
REQUIRED attribute is ignored.
FORMBUILD requires the entry of a purchase order value when adding a new
order to the database.
REVERSE
Assign the REVERSE attribute to fields you want PERFORM to display in
reverse video.
REVERSE
Usage
On computers that do not support reverse video, fields that have the
REVERSE attribute are enclosed in angle brackets (< >).
RIGHT
Assign the RIGHT attribute to fields in which you want the data to be right-
justified.
RIGHT
Usage
■ PERFORM right-justifies data you enter during an Add or Update
operation.
■ To search for a right-adjusted CHAR field of value ‘‘string’’ during a
Query operation, use the wildcard search pattern ‘‘*string’’ to
account for potential leading blanks.
UPSHIFT
Assign the UPSHIFT attribute to a CHAR field when you want PERFORM to
convert lowercase letters to uppercase letters.
UPSHIFT
Usage
Because uppercase letters and lowercase letters have different ASCII values,
storing character strings in one format or the other can simplify sorting and
querying of a database.
GLS The results of conversion between uppercase and lowercase can be made
appropriate for different languages using GLS settings. Refer to Appendix C,
“Global Language Support,” and the Informix Guide to GLS Functionality. ♦
Related Attribute
DOWNSHIFT
VERIFY
Use the VERIFY attribute when you want PERFORM to require users to enter
data twice for a particular field to reduce the probability of erroneous data
entry.
VERIFY
Usage
Because some data is critical, the VERIFY attribute supplies an additional step
in data entry to ensure the integrity of the data in your database. After you
enter a value into a VERIFY field and press RETURN, PERFORM erases the field
and requests that you reenter the value. You must enter exactly the same data
each time, character for character: 15000 is not exactly the same as 15000.00.
WORDWRAP
Use the WORDWRAP attribute when you want PERFORM to wrap a long
character string to the next field that has the same field tag.
WORDWRAP
COMPRESS
Usage
■ The keyword WORDWRAP enables the multiline editor. When you
enter text from the keyboard and reach the end of a line, the editor
brings the current word down to the next line, moving text to subse-
quent lines as necessary. When you delete text, the editor pulls words
up from lower lines whenever it can.
If you do not use the WORDWRAP attribute, words do not flow from
one line in the field to the next, and you must edit text by using the
arrow keys or the RETURN key to move from field to field.
■ The editor distinguishes between intentional blanks (blanks that you
typed or that are part of the data) and editor blanks (blanks that the
editor inserts at the ends of lines to make text wrap around to the
next line). Intentional blanks are retained as part of the data. Editor
blanks are inserted and deleted automatically as required for word
wrapping.
■ The COMPRESS attribute tells PERFORM to discard editor blanks. If
you do not use the COMPRESS attribute, and the sum of the segment
lengths exceeds the column size, PERFORM might truncate some
trailing words.
■ When you design a multiline field, allow room for editor blanks. You
can expect the average number of editor blanks per line to be half the
length of an average word.
Because the screen field whose tag is mlf appears in four physical segments
in the screen layout and has the WORDWRAP attribute, it is a multiple-line
field. Its value is composed of the physical segments taken in top-to-bottom,
left-to-right order. The field should ordinarily be as long as or longer than the
column so that it can display all of the text. It is not necessary that the
segments be the same size, as they are in the example.
VARCHARs are similar to character fields; both are supported by the multiline
editor. You must assign the WORDWRAP attribute to VARCHAR fields to
enable the multiline editor. For example, the following excerpt from a form
specification shows the VARCHAR field history in the employee table and the
attributes assigned to the field:
history [f002 ]
[f002 ]
[f002 ]
attributes
If you generate a default form for a table that has a VARCHAR column, the
VARCHAR field is broken into subscripted fields. To enable WORDWRAP,
revise the form and use the same field tag for all the components of the
VARCHAR field; then add the WORDWRAP and COMPRESS attributes.
You can use VARCHAR as the data type for a display-only (FORMBUILD) field.
You can use the DEFAULT attribute to give a VARCHAR field a default value.
ZEROFILL
Assign the ZEROFILL attribute to fields that you want to be right-justified and
padded with leading zeros.
ZEROFILL
Usage
This attribute is most useful with numeric fields. If the number entered into
the field is shorter than the field itself, PERFORM right-justifies it and fills the
leading blanks with zeros.
INSTRUCTIONS Section
The final section of the form specification file is the optional INSTRUCTIONS
section. This section is used for the following tasks:
■ Establishing composite joins
■ Specifying alternative field delimiters
■ Creating master/detail relationships
■ Defining control blocks
You can also call C functions from within the INSTRUCTIONS section. For
details, see Chapter 6, “Functions in ACE and PERFORM.”
INSTRUCTIONS
Section
COMPOSITES
INSTRUCTIONS Section
p. 2-67
END
DELIMITERS
Section
p. 2-69
MASTER OF
Section
p. 2-70
Control Block
Section
p. 2-72
COMPOSITES
Establish a COMPOSITE JOIN between two tables when you must specify the
values of more than one column in a table to specify a row uniquely.
COMPOSITES
Section
, ,
COMPOSITES is the keyword indicating that the following sets of column names
enclosed in angle brackets (< >) are to be treated as composite
columns that are joined to each other.
[Link] (where J = 1, 2, 3, ...) is a column in table1.
[Link] (where J = 1, 2, 3, ...) is a column in table2.
* indicates that the join is a verify join—that is, unless the marked
composite exists in table2, PERFORM does not allow the corre-
sponding row to be written to table1.
Usage
■ If you use an alias in the TABLES section, you must use that alias to
refer to the table in the composite join.
■ Each column included in a composite join must also be individually
joined in the ATTRIBUTES section of the form specification. This
means that table1.col1 must be joined individually to table2.col1 in the
ATTRIBUTES section, as must table1.col2 to table2.col2, and so on.
■ There can be no additional joins between columns of the two tables
that are not included in the composite join.
■ If the columns in a composite join are not individually and jointly
indexed, cross-table queries do not run as quickly.
The stock_num and manu_code fields in the items and stock table are
included in a composite join. This is a composite verify join. When the items
table is active, values entered in the stock_num and manu_code fields are
compared with values existing in those two columns in the stock table.
PERFORM notifies the user if there is not a match and rejects the entry. This
precludes the entry of stock numbers and manufacturer codes that individ-
ually exist in the database but, as a composite, do not correspond to a unique
row in the stock table.
To specify a unique row in the stock table requires both the stock_num and
manu_code. For example, the stock table contains three rows with the stock
number 1, and four rows with the manufacturer code HRO. (See Appendix A,
“The Demonstration Database and Examples,” for a list of data included in
the sample database.) Knowing the stock number or manufacturer code
alone does not allow you to locate a unique row. You need both the stock
number (1) and the manufacturer code (HRO) to specify a unique row
(baseball gloves produced by Hero) in the table.
DELIMITERS
You can change the delimiters that PERFORM uses to enclose the fields when
the form appears on the screen. The default delimiters are brackets ( [ ] ), but
you can substitute any other printable character, including blank spaces.
DELIMITERS
Section
DELIMITERS "ab"
Usage
■ The DELIMITERS instruction tells PERFORM the symbol to use as a
delimiter when it displays the fields on the screen.
■ Each delimiter is a single character only.
■ FORMBUILD still requires that you use brackets in the
form specification file.
■ If your form has columns from more than one database table, you
might not want to use blank spaces as delimiters. If you use blank
spaces, you have no visual indication on the screen of which fields
correspond to columns in the active table.
■ You can use the | bar symbol to denote both a closing delimiter and
an opening delimiter. For example,
Name [tag1 |tag2 ]
tag1 identifies the first display field; tag2 identifies the second
display field. If you use the bar symbol in the SCREEN section, you
must include a DELIMITERS statement in the INSTRUCTIONS section
of the form specification. Use two identical symbols for the left and
right delimiter in the DELIMITERS statement.
MASTER OF
Create a master/detail relationship between two tables when a row of one
table (master) is associated with several rows of another table (detail).
MASTER OF
Section
Usage
■ If you have used an alias in the TABLES section, you must use that
alias to refer to the table in the master/detail relationship.
■ You cannot include a temporary table in your table list.
■ The master/detail relationship simplifies cross-table queries,
especially when one row of table1 is associated with several rows of
table2.
■ Master/detail relationships can be defined in both directions.
■ If no explicit master/detail relationship exists, PERFORM displays an
error message when you use the Master or Detail option.
These master/detail relationships are useful because each customer can have
many orders, and each order can have many items.
Master Detail
projects personnel
orders items
agents clients
parents children
Assume that you want to query the database to find all employees who work
with a particular employee, but you do not know on which project they work.
When you identify and bring the particular employee to the screen (the
personnel table is active) and select the Detail option, PERFORM moves to the
PROJECT INFORMATION screen (the projects table is active) and displays the
information on the employee’s project. If you then choose the Detail option,
PERFORM selects all employees on that project and shifts to the PERSONNEL
INFORMATION screen (the personnel table is active).
Control Blocks
Use control blocks to perform these functions:
■ Control the cursor movement when you add or update a row.
■ Check the value of data you enter against criteria that depend on
other data that has already been entered.
■ Modify the data in fields after Add, Update, and Query operations.
■ Perform calculations on field values and enter the results into
another field.
■ Display aggregate information like averages and totals on columns
in the current list. (The current list is the set of rows that results from
a Query as modified by subsequent Add or Remove actions.)
■ Call C functions from PERFORM. For details, see Chapter 6.
Each control block is either a BEFORE block or an AFTER block. Screen control
actions can be taken either before or after PERFORM operations are
completed. You can use BEFORE blocks with the Add, Update, and Remove
operations. You can use AFTER blocks with the Add, Update, Query, Remove,
and Display operations.
Control Block
Section
BEFORE
Block
p. 2-73
AFTER
Block
p. 2-74
ON BEGINNING
Block
p. 6-12
ON ENDING
Block
p. 6-12
BEFORE
Use a BEFORE control block to cause PERFORM to take a series of actions
before it executes an operation.
BEFORE
Block
,
AFTER
Use an AFTER control block to cause PERFORM to take a series of actions after
it executes an option.
AFTER
Block
,
UPDATE
QUERY
REMOVE
DISPLAY
EDITUPDATE
EDITADD
EDITUPDATE
Usage
■ If you are using EDITADD or EDITUPDATE in a BEFORE control block
and the [Link] contains the names of columns only, the BEFORE
keyword instructs PERFORM to execute the actions when the cursor
moves to the corresponding field, before you enter data.
■ If you are using EDITADD or EDITUPDATE in an AFTER control block
and the [Link] contains the names of columns only, the AFTER
keyword instructs PERFORM to execute the actions when you enter
data into the corresponding field and press RETURN. PERFORM
makes all the attribute-specified checks (such as INCLUDE, VERIFY,
and so on) before executing the actions.
■ When you specify a database table or alias instead of a column in a
BEFORE block, PERFORM executes the actions before you enter any
data into the form. Using this feature, you can make PERFORM enter
defaults into fields and display comments depending on the active
table.
■ When you specify a database table or alias instead of a column in an
AFTER block, PERFORM executes the actions after you enter all the
data and press ESCAPE to complete the transaction, before the row is
written to the database. Using this technique, you can make consis-
tency checks of all the data entered and return to data entry if you
find inconsistencies.
■ In a BEFORE block, when you refer to a CHAR column that is split into
more than one field, PERFORM executes the actions before each
section of the displayed field. If you want these actions executed only
before the first section of a split field, replace the BEFORE block of the
split field with an AFTER block of the immediately preceding field.
■ If you want the actions executed only after the last section of a split
field, replace the AFTER block of the split field with a BEFORE block
of the immediately succeeding field.
The following examples are taken from the sample form specification file at
the end of this chapter. The syntax of the action statements used in these
examples is described in “Action Syntax” on page 2-82.
after editadd editupdate of quantity
let i19 = i18 * s15
nextfield = o11
After you enter a value in the quantity field (using the Add or Update
options), PERFORM calculates and places the value in the i19 (Total Price)
column, and places the cursor in the o11 (Order Number) field.
before editadd editupdate of orders
nextfield = o20
In this example, as soon as you indicate that you want either the Add or
Update options when orders is the active table, PERFORM is instructed to
move the cursor to the o20 (Customer P.O.) field. Without this instruction, the
cursor would go first to the o11 (Order Number) field because it is the first
orders field to appear in the ATTRIBUTES section of the form.
ADD
Use the ADD keyword to cause PERFORM to execute actions after the Add
operation. The action occurs after the row is written to the table.
ADD
Usage
The main use of the ADD keyword involves keeping track of the number of
rows written, computing statistics on the values entered into particular
fields, and other bookkeeping operations.
The following example is from the sample form. The action statements used
in this example are described in “Action Syntax” on page 2-82.
after add update query of items
if (total of i19) <= 100 then
let d1 = 7.50
else
let d1 = (total of i19) * .04
After you press ESCAPE following an Add, Update, or Query of the items
table, PERFORM calculates values for the d1 and d2 fields and displays the
values on the screen.
UPDATE
Use the UPDATE keyword to cause PERFORM to execute actions after the
Update operation.
UPDATE
Usage
The main use of the UPDATE keyword involves keeping track of the number
of rows written, computing statistics on the values entered into particular
fields, and other bookkeeping operations.
The following example is from the sample form specification file. The action
statements used in this example are described in “Action Syntax” on
page 2-82.
after add update query of items
if (total of i19) <= 100 then
let d1 = 7.50
else
let d1 = (total of i19) * .04
After you press ESCAPE following an Add, Update, or Query of the items
table, PERFORM calculates values for the d1 and d2 fields and displays the
values on the screen.
QUERY
Use the QUERY keyword to cause PERFORM to execute actions after the
Query operation.
QUERY
Usage
The main use of the QUERY keyword involves keeping track of the number
of rows written, computing statistics on the values entered into particular
fields, and other bookkeeping operations.
The following example is from the sample form specification file. The action
statements used in this example are described in “Action Syntax” on
page 2-82.
after add update query of items
if (total of i19) <= 100 then
let d1 = 7.50
else
let d1 = (total of i19) * .04
After you press ESCAPE following an Add, Update, or Query of the items
table, PERFORM calculates values for the d1 and d2 fields and displays the
values on the screen.
REMOVE
Use the REMOVE keyword to cause PERFORM to execute actions before or
after the Remove operation.
REMOVE
Usage
■ The main use of the AFTER REMOVE operation involves keeping
track of the number of rows removed, computing statistics on the
values entered into particular fields, and other bookkeeping
operations.
■ Use the BEFORE REMOVE operation to cause PERFORM to take one or
more actions before removing a row from a database table.
instructions
You can use the BEFORE REMOVE operation with the ABORT keyword
(see “ABORT” on page 2-83) to prevent a user from removing the last row
from a detail table.
DISPLAY
Use the DISPLAY keyword to cause PERFORM to execute actions after any of
the PERFORM operations that cause data to be displayed on the screen.
DISPLAY
Usage
The following example is taken from the sample form specification file at the
end of this chapter.
after display of orders
let d1 = 0
let d2 = 0
As soon as the data displays when the orders table is active, this control block
instructs PERFORM to set the values in the d1 (Ship Charge) and d2 (Total
Order Amount) fields to zero.
Action Syntax
This section provides the syntax of the following actions.
Action
ABORT Option
p. 2-83
COMMENTS
Option
p. 2-89
IF-THEN-ELSE
Option
p. 2-90
LET Option
p. 2-84
NEXTFIELD
Option
p. 2-87
For these actions to compile properly, you must include them in a BEFORE or
AFTER control block.
ABORT
Use the ABORT keyword in the INSTRUCTIONS section of a form specification
to end a current Add, Update, or Remove action without altering the
database and return to the PERFORM menu.
Abort Option
ABORT
Usage
■ The ABORT action compares to the NEXTFIELD EXITNOW action in
the following respects:
❑ With NEXTFIELD EXITNOW, PERFORM executes an Update,
Remove, or Add, and then exits to the PERFORM menu.
NEXTFIELD EXITNOW is equivalent to pressing ESCAPE.
❑ With ABORT, PERFORM exits to the PERFORM menu without
executing an Update, Remove, or Add. ABORT is equivalent to
pressing CONTROL-C.
■ You can use the ABORT keyword with the EDITADD, EDITUPDATE,
and REMOVE options.
For example, suppose you maintain a master table with employee
information and a detail table with information about employee
projects (joined to the master table by employee number). Projects
are added and deleted on a regular basis, and you want to ensure
that all employees have projects. (It is an administrative or clerical
error to remove the last detail row, thereby leaving the employee
with no project.) You can use the ABORT keyword with the BEFORE
REMOVE operation to call a C function that checks the number of
rows in the detail table. If the current row is the last detail row, the
operation aborts. For information about calling C functions from
PERFORM, see Chapter 6, “Functions in ACE and PERFORM.”
LET
Use the LET action to attach a value to a field tag for display on the form.
LET Option
Usage
■ FORMBUILD gives an error if field-tag does not satisfy the preceding
conditions.
■ You can assign values only to fields corresponding to columns in the
active table or to display-only fields.
■ An expression is:
❑ A field tag
❑ A constant value
❑ One of the aggregate functions followed by the phrase OF
tagname, where tagname is the field tag of a database column and
not the name of a display-only field. The aggregate function
values are computed over the current list.
After you press ESCAPE following an Add, Update, or Query of the items
table, PERFORM calculates values for the d1 (Ship Charge) and d2 (Total
Order Amount) fields. If the value of the i19 (Total Price) field (all items in
the order) is less than or equal to 100, then the value of the d1 field (Ship
Charge) is set to 7.50; otherwise the value is set to the sum of the i19 (Total
Price) field times .04.
The value of the d2 (Total Order Amount) field is set to the sum of the i19
(Total Price) field plus the value in the d1 (Ship Charge) field.
NEXTFIELD
When you use the EDITADD or EDITUPDATE options, use the NEXTFIELD
action to direct the movement of the cursor. The NEXTFIELD action overrides
the default progression as determined by the ATTRIBUTES section of the
form specification file.
NEXTFIELD
Option
NEXTFIELD = field-tag
EXITNOW
Usage
■ You cannot change the active table by using the NEXTFIELD action to
move the cursor to the field of a column in a new table.
■ The NEXTFIELD EXITNOW action compares to the ABORT action in
the following respects:
❑ With NEXTFIELD EXITNOW, PERFORM executes an Update,
Remove, or Add, and then exits to the PERFORM menu.
NEXTFIELD EXITNOW is equivalent to pressing the ESCAPE key.
❑ With ABORT, PERFORM exits to the PERFORM menu without
executing an Update, Remove, or Add.
■ Because the NEXTFIELD action controls the movement of the cursor,
it is effective only after the EDITADD and EDITUPDATE options.
In this example, as soon as you indicate that you want either the Add or
Update options when orders is the active table, PERFORM is instructed to
move the cursor to the o20 column (Customer P.O.). Without this instruction,
the cursor would go first to the o11 field (Order Number) because it is the first
orders field to appear in the ATTRIBUTES section of the form.
COMMENTS
Use the COMMENTS action to display a message on the Status line of the
screen. This use of COMMENTS contrasts with the COMMENTS attribute
included in the ATTRIBUTES section that writes a message on the Comment
line.
COMMENTS
Option
COMMENTS "mstring"
BELL
REVERSE
Usage
■ If you use the REVERSE keyword, you must take care on some
monitors to account for the space required at the beginning of the
line for the control characters.
■ The message is cleared at the next keystroke. Because PERFORM
writes a message whenever a row is written, an Update or an Add is
aborted, or a Query or Remove is made, this action is useful only for
the EDITADD and EDITUPDATE keywords.
IF-THEN-ELSE
Use the IF-THEN-ELSE action to take actions that depend on the values in the
displayed fields.
IF-THEN-ELSE
Option
ELSE f-action
IF is a required keyword.
boolean-expression is a Boolean expression involving field tags that can take on the
values true and false.
THEN is a required keyword.
t-action is the action or actions to be taken if boolean-expression is true.
ELSE is a keyword.
f-action is the action or actions to be taken if boolean-expression is false.
Usage
■ A Boolean expression is a combination of logical comparisons (=, <>,
>, <, >=, <=) and logical operations (AND, OR, NOT) among expres-
sions as previously defined. You can also use the operators IS NULL
and IS NOT NULL.
■ For CHAR type fields only, a Boolean expression may be also of the
form
field-tag MATCHES "string"
where string must be enclosed within quotation marks and can
include wildcard characters as defined in the Informix Guide to SQL:
Syntax.
■ t-action and f-action are either single actions as defined in this section
or more than one such action between the keywords BEGIN and END.
A more complex example from the sample form specification file follows:
after add update query of items
if (total of i19) <= 100 then
let d1 = 7.50
else
let d1 = (total of i19) * .04
After you press ESCAPE following an Add, Update, or Query of the items
table, PERFORM calculates values for the d1 (Ship Charge) and d2 (Total
Order Amount) fields. If the value of the Total Price field (all items in the
order) is less than or equal to 100, then the value of the d1 field (Ship Charge)
is set to 7.50; otherwise, the value is set to the sum of the Total Price field times
.04.
The value of the d2 (Total Order Amount) field is set to the sum of the Total
Price field (all items in the order) plus the value in the Ship Charge field.
GLS The results that character comparisons and OF MATCHES, LIKE and
BETWEEN expressions contain character arguments are dependent on GLS
collation settings. Refer to Appendix C, “Global Language Support,” and the
Informix Guide to GLS Functionality. ♦
screen
{
================================================================================
================================================================================
CUSTOMER INFORMATION:
Company: [c4 ]
First Name: [c2 ] Last Name: [c3 ]
Address: [c5 ]
[c6 ]
================================================================================
================================================================================
}
screen
{
================================================================================
CUSTOMER NUMBER: [c1 ] COMPANY: [c4 ]
ORDER INFORMATION:
Order Number: [o11 ] Order Date: [o12 ]
SHIPPING INFORMATION:
Customer P.O.: [o20 ] Ship Charge: [d1 ]
}
end
tables
customer items stock
orders manufact
attributes
c1 = *customer.customer_num
= orders.customer_num;
c2 = fname,
comments = "Please enter initial if available";
c3 = lname;
c4 = company, reverse;
c5 = address1;
c6 = address2;
c7 = city;
c8 = state, upshift, autonext,
include = ("CA","OR","NV","WA"),
default = "CA" ;
c9 = zipcode, autonext;
c10 = phone, picture = "###-###-####x####";
o11 = *orders.order_num = items.order_num;
o12 = order_date, default = today, format = "mm/dd/yyyy";
i13 = items.stock_num;
= *stock.stock_num, noentry, noupdate, queryclear;
i16 = items.manu_code, lookup m17 = manufact.manu_name
joining *manufact.manu_code, upshift, autonext;
= *stock.manu_code, noentry, noupdate,
upshift, autonext, queryclear;
s14 = [Link], noentry, noupdate;
s16 = stock.unit_descr, noentry, noupdate;
s15 = stock.unit_price, noentry, noupdate;
i18 = [Link], include = (1 to 50),
comments = "Acceptable values are 1 through 50" ;
i19 = items.total_price;
o20 = po_num, required,
comments = "If no P.O. Number enter name of caller" ;
a = backlog, autonext;
o21 = ship_date, default = today, format = "mm/dd/yyyy";
o22 = paid_date, format = "mm/dd/yyyy";
o23 = ship_instruct;
d1 = displayonly type money;
d2 = displayonly type money;
instructions
let d1 = 0
let d2 = 0
end
■ The i13 (Stock Number) and i16 (Manufacturer) fields are members
of a composite join between the items and stock tables. This is a
composite verify join, so no values can be entered in the stock_num
and manu_code fields (when the items table is active) that do not
already exist in those two columns in the stock table. This precludes
entry of stock numbers and manufacturer codes that individually
exist in the database but, as a composite, do not correspond to a
unique row in the stock table.
To specify a unique row in the stock table requires both the
stock_num and manu_code. For example, the stock table contains
three rows with the stock number 1 and four rows with the manufac-
turer code HRO. Knowing the stock number or manufacturer code
alone does not allow you to locate a unique row. You need both the
stock number (1) and the manufacturer code (HRO) to specify a
unique row (baseball gloves produced by Hero) in the table.
■ Once the i13 (Stock Number) and i16 (Manufacturer) fields are filled,
PERFORM can locate the corresponding unique row in the stock
table. The s14 (Description), s16 (Unit), and s15 (Unitprice) fields
automatically display this information.
■ The i16 (Manufacturer) field is involved in a lookup join that locates
the appropriate manufacturer name in the manufact table and places
this information in the m17 field.
■ The i18 (Quantity) field allows the entry of values 1 through 50 only,
and it displays a comment when the cursor moves into the field. This
helps to prevent mistaken entries of an extra digit (for example, 100
in place of 10).
■ The cursor does not visit the o11 (Order Number) field when the
orders table is the active table because the order_num column in the
orders table is a SERIAL data type.
■ The following entry in the INSTRUCTIONS section tells PERFORM that
when the orders table is the active table, the cursor first goes to the
o20 (Customer P.O.) field, rather than the o12 (Order Date) field:
before editadd editupdate of orders
nextfield = o20
■ The default value for field o21 (Ship Date) is set to today.
This chapter is divided into two parts. The first part describes the following
PERFORM procedures:
The second part of this chapter discusses each PERFORM option. The options
are listed in alphabetical order.
Running PERFORM
PERFORM uses the file that FORMBUILD generates when you compile a form
specification file. This file must be in your working directory or a directory
included in your DBPATH environment variable.
You can use PERFORM from the INFORMIX-SQL Main menu or directly from
the operating system. For information about command-line usage, see
Appendix G, “Accessing Programs from the Operating System.”
Select the Run option on the FORM menu. The RUN FORM screen is displayed
with a list of available screen forms.
customer
orderform
sample
Type the name of the form you want to use or use the Arrow keys to highlight
your choice on the screen. Press RETURN. The form you select appears on the
screen with the PERFORM menu, as shown in the following figure.
CUSTOMERS
Customer Number: [ ]
Company :
First Name: [ ] Last Name: [ ]
Address : [ ]
[ ]
Telephone : [ ]
__________________________________________________________________________
_____________________________________________________________________________
PERFORM: Query Next Previous View Add Update Remove Table Screen . .
.
Searches the active database table. ** 1: customer table**
The ellipsis on the first menu page indicates that additional menu items are
available on the second menu page. The ellipsis on the second menu page
indicates that additional menu items are available on the previous menu
page.
Tip: The number of options that appears on the first menu page depends on the
character capacity of your screen. The two-page screens displayed here demonstrate
a terminal or monitor with an 80-character screen. Terminals with a larger character
capacity show more options on the first menu page.
Use the SPACEBAR or the Arrow keys to move the highlight onto the menu
options. When you move the highlight past the first or last menu option on a
page, the alternate menu page appears; the menu does not scroll. The
highlight never rests on the ellipses; when you move the highlight past the
last or first option on each screen page, the next PERFORM menu page
appears.
Query retrieves rows from the database based on search values you
enter on the form and stores the rows in the current list.
The Information lines also indicate the number and name or alias of the
active table. Every table included in the screen form has a table number
assigned according to the order in which display field tags (including joins)
for the table first appear in the ATTRIBUTES section of the form specification
file. This number appears next to the table name in the right-hand corner of
the second Information line when the table is active. The table number is
useful for nonsequential moves to another table using the Detail and Table
options.
A screen form may be one page or several pages long and can contain
columns from several tables. All tables included in a form must be part of the
same database.
Here is how the PERFORM screen looks when you use the customer form
included with the demonstration database.
CUSTOMERS
Customer Number: [ ]
Company :
First Name: [ ] Last Name: [ ]
Address : [ ]
[ ]
Telephone : [ ]
______________________________________________________________________________
______________________________________________________________________________
Status Lines
PERFORM uses the last two lines of the screen to display PERFORM error
messages, as well as any messages generated by the form itself.
The two entries were not the same - please try again.
Entering Data
Use the Add and Update options to enter data directly into the database from
the screen form. You must enter data of the type specified when the table was
created—dates in DATE fields, money in MONEY fields, and so on. If you
make a mistake entering data, you can use the field-editing keys to correct it.
(See “Field Editing” on page 3-14.)
Data Types
The following list discusses the kind of data to enter for each data type. If you
enter data of the wrong type, PERFORM displays the following message on
the Status line:
Error in field
Enter an acceptable value or press the Interrupt key to cancel the option you
are using. You can use the Info options on the SQL or TABLE menu to find out
the data type for each column in a table. For more information about data
types, see the INFORMIX-SQL User Guide.
BYTE You can use the View option of the PERFORM menu to
display BYTE fields that are referenced in your form with
the PROGRAM attribute. You can display but not change
the contents of a BYTE field.
CHAR[(n)] Enter letters, numbers, and symbols. During an Add or
Update, the character data string can be as long as the
display field.
CHARACTER is a synonym for CHAR.
SMALLINT Enter a whole number from -32,767 to +32,767.
INTEGER Enter a whole number from -2,147,483,647 to
+2,147,483,647.
INT is a synonym for INTEGER.
SERIAL PERFORM assigns SERIAL values automatically, so you
never add data to a SERIAL field or update it. However,
you can enter search values in SERIAL fields when you use
the Query option.
TEXT You can only display the contents of a TEXT field; you
cannot change it.
VARCHAR Enter letters, numbers, and symbols. During an Add or
Update, the character data string can be as long as the
display field.
GLS The numeric and decimal separators can be tailored using GLS settings. These
settings change the separators displayed on the screen in a numeric or
monetary field. For example, 1234.56 will display as 1234,56 in a French or
German locale. Also, in the French or German locale values input by the user
will be expected to contain commas, not periods, as decimal separators.
Special Functions
As you enter data or a query, three special functions are available by using
selected keys.
Execute ESCAPE runs the option you select. To add a new row, type a to
select the Add option, enter the information for the row, and press
ESCAPE to add the row to the database.
Next Field The RETURN and [ ↓ ] keys move the cursor to the next field.
Backspace The BACKSPACE and [ ← ] keys move the cursor backward one
character at a time without erasing any text. Pressing either key at
the beginning of a field moves the cursor to the previous field.
Forward The [ → ] key moves the cursor forward one character at a time
without erasing any text. Pressing the [ → ] key at the end of a field
moves the cursor to the next field.
Fast Forward CONTROL-F moves the cursor down the screen rapidly, stopping
in the first field on each line. Use CONTROL-F to move quickly to
the bottom of a form that contains many fields.
Field Editing
If you make a mistake entering data in a field, you can correct it by
backspacing and retyping. However, you might find it faster to use the
PERFORM field-editing feature. You can use two editing modes to enter data
into a field:
■ In typeover mode, the characters you type replace existing data. For
example, you could use typeover mode to change “Sports ’R Us” to
“Abe’s Sporting Goods.”
■ In insert mode, the characters you type push existing data to the right.
For example, you could use insert mode to add an i to Rchard.
Whenever the cursor enters a field, PERFORM is in typeover mode; you must
press the Insert key to activate the insert mode. Press the Insert key or
CONTROL-A a second time to return to typeover mode. Move the cursor into
a new field, and you are automatically in typeover mode.
Backspace The BACKSPACE and [ ← ] keys move the cursor back one
character at a time without erasing any text. If you press
either key at the beginning of a field, the cursor moves back
to the previous field.
Clear Screen CONTROL-C clears any search criteria you have entered
with the Query option.
database reference
screen
{
TITLE: [b001 ]
AUTHOR: [b002 ]
SYNOPSIS: [b003 ]
[b003 ]
[b003 ]
[b003 ]
}
tables
booktab
attributes
b001 = [Link]
b002 = [Link]
b003 = [Link],WORDWRAP COMPRESS
.
.
.
You invoke the multiline editor by using the WORDWRAP attribute (see
“WORDWRAP” on page 2-63 for detailed information). Most keys function
the same in multiline editing as they do in normal field editing, with a few
exceptions.
RETURN RETURN causes the cursor to leave the current multiline field
and move to the first position in the next field.
Up Arrow The [ ↑ ] key moves the cursor one line up within the same
multiline field. The cursor moves to the left if necessary to
avoid editor blanks (see “WORDWRAP” on page 2-63). If the
cursor is on the top line of a multiline field, the [ ↑ ] key
moves the cursor to the first character position in the
preceding field.
Down Arrow The [ ↓ ] key moves the cursor one line down within the same
multiline field. The cursor moves to the left if necessary to
avoid editor blanks. If the cursor is on the bottom line of a
multiline field, the [ ↓ ] key moves the cursor to the first
character position in the following field.
TAB If you are in typeover mode, TAB moves the cursor to the next
field.
CONTROL-N CONTROL-N inserts a newline character, causing subsequent
text to move to the first position in the following line of the
same multiline field. This could cause text to ripple down
toward the bottom of the field, and you might lose the text
that was in the last line of the field.
Data Checking
The attributes and instructions in the form file can affect data entry, data
storage, data display, and cursor movement when you use the Add, Update,
and Query options. If you get undesired displays or cursor movement, you
can modify the form file. The effects of some attributes and instructions are
listed here, followed by the relevant options. For details about attributes and
instructions, see Chapter 2.
■ The case of the character data on the screen is different from what
you type. Check for UPSHIFT and DOWNSHIFT attributes (Add,
Update, Query).
■ SMALLFLOAT or FLOAT data on the screen is different from what you
type. Check for a FORMAT attribute that causes rounding off by
specifying the number of places to the right and left of the decimal
point (Add, Update).
■ PERFORM displays the following message:
This value is not among the valid possibilities.
Check for an INCLUDE attribute that specifies acceptable values and
ranges of values (Add, Update).
■ The terminal beeps and does not echo your entry on the screen.
Check for a PICTURE attribute that limits data entry to a specified
pattern of variables and literals (Add, Update).
■ The cursor skips over a bracketed display field. If the field is not a
SERIAL field, check for a NOENTRY attribute (for Add only), a
NOUPDATE attribute (for Update only), or a NEXTFIELD action (both
Add and Update).
■ PERFORM displays the following message:
This field requires an entered value.
Check for a REQUIRED attribute (Add). You must explicitly enter all
values for a field with the REQUIRED attribute unless you have
specified a value with DEFAULT.
■ PERFORM displays the following message:
Please type again for verification.
Check for a VERIFY attribute (Add, Update).
■ Data you enter appears on the screen justified to the right. Check for
a RIGHT attribute (Add).
■ Number data appears on the screen justified to the right and padded
with leading zeros. Check for a ZEROFILL attribute (Add).
■ A value you did not enter appears in a field. Check for a DEFAULT
attribute, a PICTURE attribute with literals (Add, Query), a joined
field (Add, sometimes Query), or a LET action (Add).
■ The cursor moves automatically to the next field after this field is full.
Check for an AUTONEXT attribute (Add, Update).
■ A line of text appears on the screen. Check for a COMMENTS attribute
(Add, Update, Query).
■ A line of text appears on the screen, in regular or reverse video,
and/or the terminal bell rings. Check for a COMMENTS action (Add,
Update, Query).
■ Data stores automatically before you press ESCAPE. Check for a
NEXTFIELD EXITNOW action (Add, Update).
■ PERFORM displays the following message:
This is an invalid value--it does not exist in
tablename.
Check for a verify join (Add, Update).
Use the Info option on the SQL or TABLE menu to find out the access
privileges for a particular table.
See the Informix Guide to SQL: Syntax for more information about privileges.
The Query, Next, Previous, Remove, and Update options all involve the
current list. The Query option finds all rows that satisfy the search conditions
and puts them in the current list. The Next and Previous options step through
the rows in the current list in sequential order. The Update and Remove
options can only work with rows in the current list.
Menu Options
The menu options you can use with PERFORM are described in detail on the
following pages. They are listed in alphabetical order, rather than menu
order, for easy reference.
ADD
Use the Add option to create new rows in the active table. You can type data
on a screen form, review it, edit it, and store it in the database.
Usage
■ If PERFORM displays this message, it does not store a row when you
press ESCAPE:
Could not insert new row - duplicate value in a unique
index column
You are trying to enter a duplicate value where it is not permitted.
Use the Info option on the SQL or TABLE menu (or execute an INFO
statement) to check for unique indexes.
■ Tables may be fully or partly unavailable to you because another
user has invoked the LOCK TABLE statement or because another user
is updating a row that you attempt to update or remove. In such a
case, PERFORM displays an error message.
■ PERFORM sometimes introduces a slight discrepancy when you enter
numbers in SMALLFLOAT or FLOAT fields. The entry 1.11, for
example, might display as 1.11000001 after you press RETURN or
ESCAPE. This discrepancy occurs because of the way a computer
stores numbers internally.
Related Options
Update, Remove
CURRENT
The Current option rereads and redisplays the current row in the current list
for the active table.
Usage
The Current option is useful in two situations:
DETAIL
The INSTRUCTIONS section of the form file can include one or more master-
detail table relationships for tables with join fields to simplify multitable
queries. The Detail option automatically selects, displays, and queries the
detail table of the active table.
Usage
■ If no explicit master/detail relationship exists, PERFORM displays an
error message when you use the Master option or the Detail option
without a table number.
■ If more than one detail table has been specified for a master table in
the INSTRUCTIONS section, type d to display and query the first
detail table; type d preceded by the number of another detail table to
display and query the other detail tables.
■ You use a table number to query any detail table that joins the active
table, even if no master-detail relationship is specified. Type 4d; if
table number 4 joins the active table, PERFORM queries table number
4 and it becomes the new active table. However, PERFORM displays
an error message when you type d without a table number if no
master-detail relationship has been specified in the INSTRUCTIONS
section.
Related Option
Master
EXIT
Use the Exit option to exit from PERFORM.
MASTER
Use the Master option to move directly from a detail table to its master table.
Related Option
Detail
NEXT
Use the Next option to step forward through the rows in the current list.
1. Use the Query option to put the rows you want to inspect in the
current list.
2. Type n to run the Next option. PERFORM displays the next sequential
row in the current list.
3. Type n repeatedly. When you reach the last row in the current list,
PERFORM displays the following message:
There are no more rows in the direction you are going.
Usage
If you want to move forward several rows at once, enter a number before the
Next option; for example, entering 10n skips ahead 10 rows.
Related Options
Query, Previous
OUTPUT
You can use the Output option on the PERFORM menu to write one or all rows
in the current list to a new or existing file.
You can produce an output file in which rows appear just as they do on your
screen, including data, display field labels, boxes, lines, and so on. Alterna-
tively, you can produce an output file in which rows appear just as they do
when you run an UNLOAD statement. Rows retrieved using this alternative
method appear in an ASCII file, one row per record, with fields separated by
the default delimiter. You can use a file in this Unload format with the ACE
READ statement to produce a report.
1. Select the Query option of the PERFORM menu to retrieve a list of the
row or rows that you want to write to a file. If necessary, use the Next
or Previous options to display the single row that you want to write
to the file.
2. Type o to select the Output option. PERFORM prompts you for a
filename:
Enter output file (default is [Link]):
3. Press RETURN to accept the default filename. Alternatively, type the
name of a file in which to store your output and press RETURN. If you
want to store your output in a different directory, make sure you
include the complete pathname. The name you enter becomes the
new default filename of the Output option for the rest of the session,
or until you enter another, different, filename.
PERFORM displays the FORM OUTPUT FILE menu as follows.
5. Type c or press RETURN if you want to store every row in the current
list. Type o to store only the row that currently appears on your
screen.
PERFORM prompts you for the format of the output file.
Usage
■ If you select the Screen-format option on the OUTPUT FORMAT
menu, PERFORM copies one page of a screen form for each row in the
current list. To copy a row that occupies more than one screen, you
must use the Output option separately with each screen.
If you want to copy all the screens of a three-screen form, for
example, perform the following operations:
1. Type O, A, C, and S to select the Output, Append, Current-List,
and Screen-format options to copy all the first screens in the
current list to a file.
2. Select the Screen option to display the second screen.
3. Repeat the same Output options to copy the second screen.
4. Use Screen to display the third screen, and then type O, A, C,
and S to append the third screen to the file.
If the query retrieves multiple rows, the file contains all the first
screens, followed by all the second screens, and so on.
PREVIOUS
Use the Previous option to display prior rows in the current list.
1. Use the Query option to put the rows you want to look at in the
current list.
2. Type n to display the next row.
3. Type p to use the Previous option. PERFORM displays the previous
row (in this case, the first row) in the current list.
4. When you reach the first row in the current list, type p. PERFORM
displays the following message:
There are no more rows in the direction you are going.
5. You can use the Previous option whenever you want to display prior
rows in the current list.
Usage
If you want to move backward several rows at once, enter a number before
the Previous option; for example, entering 10p skips back 10 rows.
Related Options
Query, Next
QUERY
Use the Query option to search for database rows and columns with specified
values based on search values you enter directly into the display fields on a
screen form. You can specify the search criteria with 11 different query
operators, including 6 relational operators, 2 range operators, 2 wildcard
operators, and highest/lowest value operators. PERFORM finds all the
database rows that satisfy the conditions and puts them in the current list.
You can use the Next and Previous options to view them.
= equal to all =x
INTERVAL
| or all a|b
Enter the equal sign by itself to search for a database row that contains
a null CHAR column; enter =* to find a row that contains a column with
an asterisk.
x Any search value with the appropriate data type for the search field.
Enter the search value immediately after any one of the first six query
operators in the previous table. Do not leave a space between the query
operator and the search value.
> For CHAR data, greater than means later in ASCII order (a>A>1). For
DATE or DATETIME data, greater than means after. (See Appendix E,
“The ASCII Character Set,” in this manual for more information.)
< For CHAR data, less than means earlier in ASCII order (1<A<a). For
DATE or DATETIME data, less than means before.
: The search operator that specifies a range. You must give the lower
value before the search operator and the higher value after the operator
in a range query. Queries with the range operator are inclusive. The
search criterion 1:10 would find all rows with a value in that column
from 1 through 10, inclusive.
Usage
■ Because of the way a computer stores floating-point numbers, you
might not be able to retrieve FLOAT and SMALLFLOAT data by
querying for the exact value you entered. You can solve this problem
by using a range query. Specifying a FORMAT with a few places to the
right of the decimal point in the FORMBUILD ATTRIBUTES section
might also help.
■ If the RIGHT attribute is specified for a display field, you might have
to use an asterisk in front of a search value. (RIGHT does not right-
justify the search value after you enter it.)
■ Although the literals in PICTURE specifications appear on the screen
when you add and update data, they do not appear on the screen
when you query. If you enter the wrong literal value, your search will
not be successful. A COMMENTS entry in the form file can help you
avoid this problem.
GLS The evaluation of less than (<) and greater than (>) expressions that contain
character arguments is dependent on GLS settings. Refer to Appendix C,
“Global Language Support,” and the Informix Guide to GLS Functionality.♦
Related Options
Next, Previous
REMOVE
Use the Remove option to delete the row on the screen from the active table.
1. Use the Query, Next, and Previous options to display the row you
want to delete.
2. Type r to select the Remove option.
3. PERFORM displays the following screen.
REMOVE: Yes No
Removes this row from the active table.
Enter y to delete the row, or n to keep it. In either case, the PERFORM
menu appears on the screen next. The following message appears at
the bottom of the screen when you remove a row:
Row deleted
Usage
You cannot remove a verify join row from one table (generally the master
table, against which the join field is verified) unless you first remove all the
rows that join it in other tables (generally detail tables, which are verified
against the master table). For example, using the ORDERFORM form, you can
remove rows in the items table. However, you cannot remove a row in the
orders table without removing all rows in the items table that join that row
because the Order Number display field is a verify join.
Related Options
Add, Update
SCREEN
Use the Screen option to cycle through the screen pages of the form.
TABLE
Use the Table option when there is more than one table in the screen form and
you want to select a new active table. Each table is assigned a table number
assigned according to the order in which display field tags (including joins)
for the table first appear in the ATTRIBUTES section of the form file. This
number appears next to the table name or alias in the screen Information lines
when the table is active. The Table option steps through the tables in table-
number order starting with the active table.
Usage
If you know the number of the table you want to view next, you can go
directly to that table without passing through the intervening tables. For
example, suppose your form has five tables and you are looking at table
number 4. If you want to see table number 2 next, type 2t and PERFORM
displays table number 2. Tables number 5 and 1 are skipped.
UPDATE
Use the Update option to modify the data in the displayed row of the current
list.
1. Use the Query, Next, and Previous options to display the row you
want to modify.
2. Type u to run the Update option. PERFORM puts the cursor in the first
active field.
3. Edit the data, modifying as many display fields as you like.
4. Press ESCAPE to store the changed row, or the Interrupt key to ignore
the changes and display the menu again.
Usage
■ You cannot update a field that is a verify join field for another table
without first updating the relevant field in the other table.
■ If you press ESCAPE after you select the Update option, PERFORM
displays the following message whether or not you actually changed
anything:
This row has been changed.
■ PERFORM sometimes introduces a slight discrepancy when you enter
numbers in SMALLFLOAT or FLOAT fields. The entry 1.11, for
example, might display as 1.11000001 after you press RETURN or
ESCAPE. This discrepancy occurs because of the way a computer
stores numbers internally.
VIEW
Use the View option to display the contents of TEXT fields and of BYTE fields
that are referenced in your form with the PROGRAM attribute. Blobs (Binary
Large OBjects) include the TEXT and BYTE data types. You can only display
the contents of the blob. You cannot change the blob from within the
PERFORM form.
When you select the View option, INFORMIX-SQL positions the cursor on the
first TEXT field, or the first BYTE field that uses the PROGRAM attribute. To
display the blob, type an exclamation point (!). Press RETURN, TAB, or the
down arrow key to skip to the next blob field that can be displayed; type an
up arrow key to move to the previous blob field. Press ESCAPE to exit the
View option and to redisplay the Main menu.
If you select the View option and the form contains no blob fields,
INFORMIX-SQL displays the following error message:
Statements . . . . . . . . . . . . . . . . . . . . . . 4-65
FOR . . . . . . . . . . . . . . . . . . . . . . . 4-66
IF THEN ELSE . . . . . . . . . . . . . . . . . . . 4-67
LET . . . . . . . . . . . . . . . . . . . . . . . 4-69
NEED . . . . . . . . . . . . . . . . . . . . . . 4-71
PAUSE . . . . . . . . . . . . . . . . . . . . . . 4-72
PRINT . . . . . . . . . . . . . . . . . . . . . . 4-73
PRINT FILE . . . . . . . . . . . . . . . . . . . . 4-75
SKIP. . . . . . . . . . . . . . . . . . . . . . . 4-76
SKIP TO TOP OF PAGE . . . . . . . . . . . . . . . . 4-77
WHILE. . . . . . . . . . . . . . . . . . . . . . 4-78
Aggregates . . . . . . . . . . . . . . . . . . . . 4-79
ASCII . . . . . . . . . . . . . . . . . . . . . . 4-82
CLIPPED . . . . . . . . . . . . . . . . . . . . . 4-84
■ You can use the Report option on the ISQL (INFORMIX-SQL) Main
menu.
■ You can work directly with the appropriate programs from the
operating-system command line.
Either alternative requires that you have already created the database and all
the tables from which the report will draw information. The following two
sections describe these alternative procedures. They do not, however,
describe the rules for constructing or modifying the report specification file.
These rules are defined in “Information About ACE” on page 4-10.
1. Select the Report option on the INFORMIX-SQL Main menu and then
the Report option on the REPORT menu.
2. If there is no current database, the CHOOSE DATABASE screen
appears. After you select a database, the GENERATE REPORT screen
is displayed. Enter the name you want to assign to the report (for
example, newrpt). Do not use the .ace filename extension;
INFORMIX-SQL automatically adds the required extension.
3. INFORMIX-SQL prompts you for the name of the table you want it to
use to create the default report. After you enter the table name,
INFORMIX-SQL automatically compiles the report specification and
displays the REPORT menu. The report is now available to be used.
4. Select the Run option on the REPORT menu to run the report.
The default report specification file formats a report as a list of all columns in
the table included in the report. It does not provide any special instructions
to ACE about how to display the data, nor does it include instructions to
perform data manipulations. Only one table contributes information to a
default report.
1. Use the system editor to create a report specification file. Append the
extension .ace to the filename.
2. Compile the specification with the ACEPREP program. Call ACEPREP
as saceprep. You can omit the .ace filename extension when you call
ACEPREP.
For example, use this command line to compile the [Link] speci-
fication file:
saceprep newrpt
3. If the compilation is successful, ACE creates a compiled report file
called [Link] and you are finished creating your customized
report. Go to step 5. If errors are detected in the report specification,
a [Link] file is created. Go to step 4.
4. Use the system editor to edit this specification. Remove all error
comments from the specification file. Overwrite the file [Link]
with this corrected version. Go to step 2.
5. To run the [Link] report, use the ACEGO program. Call ACEGO
as sacego. Do not include the .arc filename extension when you call
ACEGO.
For example, use this command line to run the [Link] report:
sacego newrpt
Command-Line Options
The following four command-line options are available for use with ACE:
-s Use the -s (silent) option with both ACEGO and ACEPREP to suppress
all nonessential screen messages. For example, use this command
line to suppress program banners in ACEPREP:
saceprep -s newrpt
You can also check for non-ANSI syntax by setting the DBANSIWARN
environment variable. See Appendix B for more information about using
DBANSIWARN.
Owner Naming
In an ANSI-compliant database, the prefix owner. must precede the table name
if the report will be run by users other than the owner. The prefix owner. is
optional in a database that is not ANSI-compliant. INFORMIX-SQL does check
the accuracy of owner. if you include it in the statement, however.
When this manual refers to a number expression (num-expr), you can supply
any type of expression, including character, as long as ACE can evaluate it as
a number. The character string ‘‘123’’ is a valid number expression, while
‘‘m23’’ is not.
Similarly, date-expr is an expression that ACE can evaluate as a date. You can
use a quoted string (‘‘01012010’’ or ‘‘1-1-2010’’) or an INTEGER that evaluates
to a legal date.
A quoted string is any string of characters in quotation marks. You can use a
quoted string anywhere ACE requires a type CHAR or VARCHAR expression.
You can name a TEXT column in a PRINT statement. The PRINT statement acts
like a PRINT FILE statement with the TEXT item as a file.
Figure 4-1
Operator Precedence
- unary minus 1
** exponentiation 2
* multiplication 3
/ division 4
+ addition 4
- subtraction 4
= equal 5
not not 6
and and 7
or or 8
Sample Reports
The sample reports in this chapter are taken from the following list.
Additional reports, included with the demonstration database, are available
for further study. These reports illustrate a variety of the commands available
with ACE.
[Link] A simple report that generates mailing labels
The ACE report specification sections must be kept in the following general
order:
DATABASE Section
Every report specification must have a DATABASE section. The DATABASE
section specifies the database ACE uses as the basis of the report. You can
override the database that you specify in this section with the -d command-
line option. See the section “Command-Line Options” on page 4-9 for more
information.
The DATABASE section must be the first section in an ACE report specifi-
cation. It begins with the DATABASE keyword, followed by the name of the
database, and ends with the END keyword.
If you want to retrieve data from an ASCII file using the READ statement, you
still must specify a database in the DATABASE section even though a report
based on an ASCII file is not related to a database. You can either specify the
name of an existing database or use the ASCII keyword.
DATABASE
Section
ASCII
DEFINE Section
An ACE report specification can optionally contain a DEFINE section. The
DEFINE section is used to declare variables used in the report and parameters
the report can accept from the command line. If you are retrieving values
from an input file using the READ statement, you must use the ASCII
keyword in the DEFINE section to specify the field names and data types for
the data in that file.
The DEFINE section begins with the DEFINE keyword and ends with the
corresponding END keyword. The variable definition list appears between
these keywords and is composed of one or more PARAM or VARIABLE state-
ments or a combination of both. You can use a single ASCII keyword and field
list between the DEFINE and END keywords.
DEFINE
Section
PARAM
Statement
p. 4-20
VARIABLE
Statement
p. 4-21
FUNCTION
Statement
p. 6-5
The next three sections describe the ASCII, PARAM, and VARIABLE
statements. The FUNCTION statement is described in Chapter 6, “Functions
in ACE and PERFORM.”
ASCII
You use an ASCII statement in a DEFINE section to specify the field names and
data types of the records in an ASCII input file. The ACE report writer accesses
this file in a READ statement.
ASCII
Statement
,
Usage
■ You must include an ASCII statement in the DEFINE section if you use
a READ statement in the READ section.
■ You cannot use a SELECT statement to access an ASCII file, nor can
you use a READ statement to access a database table.
■ Although a report based on ASCII data is not related to a database,
you must specify a database in the DATABASE section. Either specify
the name of an existing database or use the ASCII keyword.
■ The number of fields in the ASCII statement must match the number
of fields in the ASCII file.
■ Each field-name must be followed by a data type specification. ACE
does not check the accuracy of data types, so run-time errors can
occur if a data type has been specified incorrectly.
■ No further specification of the MONEY data type is permitted beyond
the keyword MONEY.
■ See the Informix Guide to SQL: Reference for information about SQL
data types.
The following ASCII statement defines a record from an ASCII file in unload
format:
define
ascii stock_num smallint, manu_code char(3),
description char(15), unit_price money,
unit char(4), unit_descr char(15)
end
In this instance, the field names happen to have the same names and
sequence as the column names in the stock table of the stores7 database. Like
the variable names of a PARAM or VARIABLE statement, the field names do
not need to match the column names of any table. The number, order, and
data types of the field names must be consistent with the fields in the ASCII
file.
Related Commands
READ, UNLOAD
PARAM
This statement allows you to use arguments specified on the command line
at the time you run an ACE report. It declares a variable whose initial value
is that of a command-line argument. To use PARAM, you must call ACE from
a custom user menu (see Chapter 5, “User-Menu”) or the command line (see
“Creating and Compiling a Custom Report” on page 4-5).
PARAM
Statement
Usage
■ You can define a total of 100 variables using PARAM and VARIABLE
statements in an ACE report specification.
■ If a report specification uses a PARAM statement and you fail to
provide arguments on the command line when you run the report,
ACE gives an error message.
■ If you want to use a variable defined by a PARAM statement in the
SELECT section, you must precede the variable name with a dollar
sign. Refer to the “SELECT Section” on page 4-37 for more
information.
■ See the Informix Guide to SQL: Reference for information about variable
data types.
VARIABLE
This statement declares a variable that you can use in an ACE report
specification.
VARIABLE
Statement
Usage
■ You can define a total of 100 variables using PARAM and VARIABLE
statements in an ACE report specification.
■ If you want to use a variable that you declare in a PARAM or
VARIABLE statement in the SELECT section, you must precede the
variable name with a dollar sign. (Refer to the “SELECT Section” on
page 4-37 for more information.)
■ No further specification of the MONEY data type is permitted beyond
the keyword MONEY.
■ VARCHAR columns and variables in expressions act the same way as
CHAR columns and variables. When you define a VARCHAR in a
report, do not give the min-space parameter with which the
VARCHAR was defined for the database. Rather, indicate how many
characters you want printed.
For example, if in the employee table history is defined as
VARCHAR(255,10), in the report you should define it as
VARCHAR(255). If you only want to output a portion of the column,
you can define VARCHAR with a shorter length, such as
VARCHAR(120).
■ See the Informix Guide to SQL: Reference for information about variable
data types.
The following example shows the use of the VARCHAR data type:
define
variable history varchar(255)
end
The user enters the values for the variables when the program runs. See the
“INPUT Section” on page 4-23 for a description of this process.
INPUT Section
An ACE report specification optionally can contain an INPUT section. The
INPUT section allows you to produce an interactive ACE report by prompting
for and accepting input while ACE is running a report.
The INPUT section consists of the keywords INPUT and END with one or more
PROMPT FOR statements in between. The following diagram shows the
structure of the INPUT section.
INPUT
Section
PROMPT FOR
INPUT Statement END
p. 4-24
PROMPT FOR
This statement prompts you while ACE is running a report and assigns the
value you enter to a variable.
PROMPT FOR
Statement
Usage
■ You cannot prompt for, or accept, a database name using the
PROMPT FOR statement. Refer to the DATABASE section and to the
discussion of the -d option in “Command-Line Options” on page 4-9.
■ You cannot prompt for, or accept, an output filename using the
PROMPT FOR statement.
The two character strings "Enter beginning date for report:" and
"Enter ending date for report:" appear as prompts on the screen when
the [Link] report runs. The response to the first prompt is entered as the
value to the begin_date variable; the response to the second prompt is entered
as the value to the end_date variable. These two variables are used at several
points in the [Link] report.
OUTPUT Section
An ACE report specification can optionally contain an OUTPUT section. The
OUTPUT section controls the width of the margins and the length of the page.
The OUTPUT section also allows you to direct the output from the ACE report
to a file or a printer.
The OUTPUT section begins with the OUTPUT keyword and ends with the
corresponding END keyword, with one or more statements in between. The
following diagram shows the structure of the OUTPUT section.
OUTPUT
Section
REPORT TO
OUTPUT Statement END
p. 4-5
LEFT MARGIN
Statement
p. 4-5
RIGHT MARGIN
Statement
p. 4-5
TOP MARGIN
Statement
p. 4-5
BOTTOM MARGIN
Statement
p. 4-5
PAGE LENGTH
Statement
4-5
TOP OF PAGE
Statement
p. 4-5
REPORT TO
This statement directs the output of the ACE report to a file or a printer.
REPORT TO
Statement
REPORT TO "filename"
PRINTER "program"
Usage
■ When you do not use one of the REPORT TO statements, ACE sends
the report to your screen.
■ You cannot use more than one REPORT TO statement in a report
specification.
■ The TO PRINTER keywords cause ACE to send the report to the
program named by the DBPRINT environment variable. If you do not
define this environment variable, ACE sends the report to the lp
program.
■ If you want to send the report to a printer other than the system
printer, you can use the REPORT TO filename statement to send the
output to a file and then send the file to the printer of your choice.
■ If the REPORT TO filename statement writes to an existing filename,
the file is replaced with the new output. You can also use the REPORT
TO PIPE statement to direct the output to a program that will send the
output to the appropriate printer.
LEFT MARGIN
This statement sets a left margin for a report.
LEFT MARGIN
Statement
Usage
The default left margin is five spaces.
The following example is from the [Link] report. ACE prints the left side
of the report as far to the left as possible.
output
top margin 0
bottom margin 0
left margin 0
page length 9
report to "labels"
end
RIGHT MARGIN
This statement sets a right margin for a report.
RIGHT MARGIN
Statement
Usage
■ The RIGHT MARGIN determines the right margin by specifying the
width of the page in characters. It does not depend on the LEFT
MARGIN but always starts its count from the left edge of the page
(space 0).
■ The RIGHT MARGIN is only effective when the FORMAT section
contains an EVERY ROW statement.
■ The default right margin is 132 characters.
output
right margin 70
end
select *
from customer
end
format
every row
end
TOP MARGIN
This statement sets a top margin for a report.
TOP MARGIN
Statement
Usage
■ The default top margin is three lines.
■ The top margin appears above any page header you specify.
Example
The following example is from the [Link] report. ACE begins printing at
the top of each page.
output
top margin 0
bottom margin 0
left margin 0
page length 9
report to "labels"
end
BOTTOM MARGIN
This statement sets a bottom margin for a report.
BOTTOM MARGIN
Statement
Usage
■ The default bottom margin is three lines.
■ The bottom margin appears below any page trailer.
In the following example, the printing continues to the bottom of each page:
output
top margin 0
bottom margin 0
end
PAGE LENGTH
This statement sets the number of lines on each page of a report.
PAGE LENGTH
Statement
Usage
■ The default page length is 66 lines.
■ The PAGE LENGTH includes the TOP MARGIN and BOTTOM
MARGIN.
The following example demonstrates the use of the PAGE LENGTH statement.
ACE prints each page with 22 lines.
output
{This length works on std 24-line crt}
page length 22
top margin 0
bottom margin 0
end
TOP OF PAGE
This statement specifies the character string that causes your printer to eject
a page.
TOP OF PAGE
Statement
Usage
■ On most printers, char-string is "^L", the ASCII form-feed character.
ACE uses the first character of the string as the TOP OF PAGE
character unless it is the ^ character. If the first character is the ^
character, ACE decodes the second character as a control character.
(If you are unsure of the character string to specify for your printer,
refer to the documentation provided with your printer.)
■ ACE places the character string in the report to advance to the next
page whenever the program causes a new page to be set up. Any of
the following items can initiate a new page:
❑ The next print line meets the bottom margin.
❑ A SKIP TO TOP OF PAGE statement is executed.
❑ A SKIP n LINES statement skips more lines than are available on
the current page.
❑ A NEEDS statement specifies more lines than are available on the
current page.
■ If you specify the TOP OF PAGE statement, ACE uses the specified
page-eject character to set up new pages instead of using line feeds.
■ If you omit the TOP OF PAGE statement, ACE fills the remaining lines
of the current page with line feeds when a new page is set up.
format
on every row
end
SELECT Section
Every report specification must have a SELECT section or a READ section. The
SELECT section specifies the columns or tables or both that the report is based
on if you retrieve data from a database. The READ section specifies the input
file the report is based on if you retrieve data from an ASCII file. See the
“READ Section” on page 4-40 for details on how to use ASCII files in ACE
reports.
You can use the SELECT section to specify criteria for selecting and ordering
rows based on the contents of specific columns. The FORMAT section can
group rows in the report based on the order you specify in the SELECT
section.
The SELECT section contains one or more SELECT statements. These state-
ments are identical to the SELECT statements described in the Informix Guide
to SQL: Syntax. This chapter does not define the SELECT statement but shows
how to incorporate it in an ACE report specification.
The SELECT section begins with the SELECT keyword. This keyword intro-
duces both the SELECT section and the first SELECT statement. Other SELECT
statements can follow the first—each must begin with the SELECT keyword.
All SELECT statements, except for the last, must end with a semicolon. (If
there is only one SELECT statement, it does not require a semicolon.) The
SELECT section ends with the END keyword. All but the last SELECT
statement must have an INTO TEMP clause.
If you use an ORDER BY clause in the SELECT section, you cannot use an
integer or a column with a table prefix ([Link]) to indicate the column
to sort by. If you cannot use the column name alone because it is not unique
or because it is an expression, define a display label in the select list and use
it in both the ORDER BY clause and the FORMAT section in the AFTER and
BEFORE GROUP OF control blocks. The second example in this section
demonstrates the use of a display label.
If you use an ACE variable in the SELECT section, you must precede the
variable name with a dollar sign. The third example in this section demon-
strates the use of a variable name.
SELECT
Section
SELECT
Statement ; END
SQLR
The following example is from the [Link] report. ACE selects all rows from
the customer table and orders the rows first by zip code and then by last
name.
select *
from customer
order by zipcode, lname
end
order by number
end
ACE selects the indicated columns from the orders and items tables. The
order_num column in the orders table is given the display label number and
is joined to the order_num column in the items table. ACE orders the rows by
the values in the number column.
ACE selects the indicated columns from the customer table. The WHERE
clause tells ACE to select only those rows where the value in the state column
matches the value in the variable thisstate. ACE orders the rows by the values
in the zipcode column first and then by lname.
READ Section
As an alternative to the SELECT section, you can include a READ section
containing a READ statement. Unlike the SELECT statement, which queries
the database for rows, the READ statement retrieves rows from an ASCII input
file. Every report specification must have either a READ section or a SELECT
section.
The READ statement allows you to retrieve data from ASCII files produced by
the UNLOAD statement of SQL or the Output option of PERFORM. In addition,
you can produce reports from ASCII files created or edited by other software
products.
The following conditions must be satisfied before you can read data from an
ASCII file:
■ You must know the complete pathname of the ASCII data file. You
must also know the number of fields, the delimiter symbol, and the
order and data type of each field of a record in the file.
■ You must use the ASCII statement in the DEFINE section of a report
specification to indicate the format of a record in the ASCII file. The
ASCII keyword is followed by an ordered list of the field names and
data types of the ASCII file. See the “DEFINE Section” on page 4-17
for details on using the ASCII statement.
■ Although a report based on ASCII data is not related to a database,
you must include a DATABASE section in the report specification. You
can either specify an existing database or use the ASCII keyword. See
the “DATABASE Section” on page 4-16 for details on using the ASCII
keyword.
READ
Section
READ
Statement END
p. 4-41
READ
Use the READ statement in the READ section to retrieve data from an ASCII
input file in unload format. The READ section specifies the name of the input
file, any nondefault delimiter, and optional sorting specifications. You use the
ASCII statement in the DEFINE section to specify the fields of each record in
the input file.
READ
Statement
READ "filename"
DELIMITER "symbol"
,
ORDER BY fieldname ASC
EXTERNAL DESC
fieldname is the name of a field in an input file record, as defined in the ASCII
statement of the DEFINE section, that is used as a sorting key.
ASC is an optional keyword specifying that the values in the fieldname
field are used to sort records in ascending order (smallest values
first).
DESC is an optional keyword specifying that the values in the fieldname
field are used to sort records in descending order (largest values
first).
Usage
■ The READ statement requires an ASCII statement in the DEFINE
section. You cannot use a SELECT statement to access an ASCII file,
nor can you use a READ statement to access a database table.
■ The default delimiter is a vertical bar (| = ASCII 124). See
Appendix B, “Setting Environment Variables,” for information on
how to specify a different default delimiter with the DBDELIMITER
environment variable.
■ ACE uses the delimiter specified in the READ statement as the field
separator, regardless of whether you have set the DBDELIMITER
environment variable.
■ An ORDER BY clause in a READ statement can list up to eight field
names as sorting keys. These names must match the field names that
are specified in the ASCII statement. Specify an existing database,
rather than use the ASCII keyword, if you are using an ORDER BY
clause.
■ If more than one sorting key is specified in an ORDER BY clause, the
primary key is the first field named in the ORDER BY list, the
secondary sorting key is the second field named in that list, and so
on.
■ If the ASCII file named in a READ statement is already sorted, and the
FORMAT section contains BEFORE GROUP OF or AFTER GROUP OF
control blocks on two or more fields, then an ORDER EXTERNAL BY
clause must specify the hierarchy of the order.
■ ACE does not allow the use of the space or double quotation mark
( " ) as a delimiter in the ASCII file.
The following READ statement specifies an ASCII file (in unload format) that
corresponds to the stock table of the stores7 database:
read "stock1" delimiter ":"
order by unit_price desc, description
end
This READ statement tells ACE to read the records in an ASCII file called
STOCK1 that uses the colon ( : ) as a delimiter, and to sort the records in
descending order according to the values in the field unit_price. Since the
description field is a secondary sorting key, records that have the same
unit_price value appear in ascending alphabetical order according to the
label in their description field.
The next example reverses the previous order of the sorting keys and sorts
unit prices in default (ascending) order:
read "stock1" delimiter ":"
order external by description, unit_price
end
. . .
format
. . .
after group of description
. . .
after group of unit_price
. . .
The ORDER EXTERNAL BY clause specifies that the stock1 file is already
sorted. Totals or subtotals specified in the AFTER GROUP OF control blocks
are printed after the groups of rows have been printed according to the
sorting instructions in the ORDER BY clause.
Related Commands
ASCII, ORDER BY (option of SELECT), OUTPUT (option of PERFORM),
UNLOAD (SQL statement)
FORMAT Section
An ACE report specification must contain a FORMAT section. The FORMAT
section determines the appearance of the report. It works with the data that
is qualified by the last (or only) SELECT statement in the SELECT section, or
with the contents of an ASCII file referenced by the READ statement in the
READ section. The FORMAT section begins with the FORMAT keyword and
ends with the corresponding END keyword as shown in the following
diagram.
FORMAT
Section
EVERY ROW
FORMAT Statement END
p. 4-44
PAGE HEADER
Control Block
p. 4-63
PAGE TRAILER
Control Block
p. 4-44
ON EVERY ROW
Control Block
p. 4-44
ON LAST ROW
Control Block
p. 4-60
BEFORE GROUP OF
Control Block
p. 4-53
AFTER GROUP OF
Control Block
p. 4-50
CALL
Statement
p. 6-7
FORMAT
EVERY ROW statement
END
EVERY ROW
The EVERY ROW statement causes ACE to output every row that the SELECT
or READ section retrieves. It uses a default format.
EVERY ROW
Statement
EVERY ROW
Usage
■ This statement is useful when you want to develop a report quickly
using a default format. The report uses as column headings the
column names you assigned when you created the table or the field
names that you assigned in the ASCII statement. Because the EVERY
ROW statement cannot contain any control blocks or other state-
ments, you cannot alter the default format to create a custom report.
■ The EVERY ROW statement stands by itself—you cannot modify it
with any of the statements listed in “Statements” on page 4-65.
■ When you use the EVERY ROW statement, you cannot use any control
blocks in the FORMAT section.
■ A report generated by an EVERY ROW statement uses the column
names you assigned when you created the table.
■ If the columns that you specify in the SELECT section, or the values
that you retrieve in the READ section, fit on one line, ACE produces a
report with column or field names across the top of each page;
otherwise, ACE produces a report with the column or field names
down the left side of the page.
■ You can use the RIGHT MARGIN statement in the OUTPUT section to
control the width of a report that uses the EVERY ROW statement.
■ Use the ON EVERY ROW control block if you want to display every
row in a format other than the default format. (See the discussion of
“ON EVERY ROW” on page 4-58.)
The following example shows a minimal ACE report specification using the
EVERY ROW statement:
database
stores7
end
select *
from customer
end
format
every row
end
The following example shows a portion of the output from the preceding
specification:
customer_num 101
fname Ludwig
lname Pauli
company All Sports Supplies
address1 213 Erstwild Court
address2
city Sunnyvale
state CA
zipcode 94086
phone 408-791-8075
customer_num 102
fname Carole
lname Sadler
company Sports Spot
address1 785 Geary St
address2
city San Francisco
state CA
zipcode 94117
phone 415-822-1291
customer_num 103
fname Philip
lname Currie
.
.
.
format
every row
end
The following example shows the output from the preceding specification:
order_num customer_num order_date
Control Blocks
Control blocks provide the structure for a custom report. The control blocks
that you can use in a FORMAT section follow:
■ AFTER GROUP OF
■ BEFORE GROUP OF
■ FIRST PAGE HEADER
■ ON EVERY ROW
■ ON LAST ROW
■ PAGE HEADER
■ PAGE TRAILER
Each control block is optional, but if you do not use the EVERY ROW
statement, you must include at least one control block in a report
specification.
Each control block must include at least one statement. (See “Statements” on
page 4-65.) If you have INFORMIX-ESQL/C, you can also call C functions from
within a control block. See the INFORMIX-ESQL/C Programmer’s Manual and
Chapter 6, “Functions in ACE and PERFORM,” for details.
When you use an ORDER BY clause in the SELECT or READ section of an ACE
report specification, you can use BEFORE GROUP OF and AFTER GROUP OF
control blocks in the FORMAT section. When you use the BEFORE GROUP OF,
AFTER GROUP OF, and ON EVERY ROW control blocks in a single report speci-
fication, ACE processes the control blocks in the order shown in Figure 4-2.
(The figure assumes that the SELECT or READ section orders by columns a, b,
and c.)
Figure 4-2
Order of Group Processing
before group of a
before group of b
before group of c
on every row
after group of c
after group of b
after group of a
AFTER GROUP OF
The AFTER GROUP OF control block specifies what action ACE takes after it
processes a group of rows. Grouping is determined by the ORDER BY clause
of the SELECT or READ section.
AFTER GROUP OF
Control Block
[int1 ]
,int2
Usage
■ A group of rows is all the rows that contain the same value for a given
column. ACE automatically groups rows when you use an ORDER BY
clause in the SELECT or READ section of a report specification (that is,
groups come together when you order a list).
When you specify more than one column in an ORDER BY clause,
ACE orders the rows first by the first column you specify (most
significant), second by the second column you specify, and so on,
until the last column you specify (least significant).
ACE processes the statements in an AFTER GROUP OF control block
each time the specified column changes value, each time a more
significant column changes value, and at the end of a report. (See
Figure 4-2 on page 4-49.)
skip 1 line
print 4 spaces, "Shipping charges for the order: ",
ship_charge using "$$$$.&&"
skip 1 line
BEFORE GROUP OF
The BEFORE GROUP OF control block specifies what action ACE is to take
before it processes a group of rows. Grouping is determined by the ORDER
BY clause of the SELECT or READ section.
BEFORE GROUP OF
Control Block
[ int1 ]
, int2
Usage
■ A group of rows is all the rows that contain the same value for a given
column. ACE automatically groups rows when you use an ORDER BY
clause in the SELECT or READ section of a report specification (that is,
groups come together when you order a list).
When you specify more than one column in an ORDER BY clause,
ACE orders the rows first, by the first column you specify (most
significant), second, by the second column you specify, and so on,
until the last column you specify (least significant).
ACE processes the statements in a BEFORE GROUP OF control block
at the start of a report, each time the specified column changes value,
and each time a more significant column changes value. (See
Figure 4-2 on page 4-49.)
skip 1 line
print "Stockno", column 20,
"Mfcode", column 28, "Qty", column 38, "Price"
Usage
■ The vertical size of the first page header is equal to the number of
lines that you specify in the FIRST PAGE HEADER control block. The
TOP MARGIN (in the OUTPUT section) affects how close to the top of
the page ACE displays the page header.
■ A FIRST PAGE HEADER control block overrides a PAGE HEADER
control block on the first page of a report.
■ You cannot use the SKIP TO TOP OF PAGE statement in a FIRST PAGE
HEADER control block.
■ If you use an IF THEN ELSE statement in a FIRST PAGE HEADER
control block, the number of lines displayed by the PRINT and SKIP
statements following the THEN keyword must be equal to the
number of lines displayed by the PRINT and SKIP statements
following the ELSE keyword.
■ You cannot use the PRINT FILE statement to read and display text
from a file in a FIRST PAGE HEADER control block.
■ You can use a FIRST PAGE HEADER control block to produce a title
page as well as column headings.
let i = 1
This FIRST PAGE HEADER does not display any information. Because ACE
executes the FIRST PAGE HEADER control block before it generates any output,
you can use this control block (as demonstrated in the example) to initialize
variables that you use in the FORMAT section.
ON EVERY ROW
The ON EVERY ROW control block specifies what action ACE takes after the
SELECT section qualifies a row, or after the READ section retrieves a row.
ON EVERY ROW
Control Block
Usage
■ ACE processes the statements in an ON EVERY ROW control block as
each new row is formatted.
■ If a BEFORE GROUP OF control block is triggered by a change in
column value, all BEFORE GROUP OF control blocks are executed
(in the order of their significance) before the ON EVERY ROW control
block is executed.
■ If an AFTER GROUP OF control block is triggered by a change in
column value, all AFTER GROUP OF control blocks are executed (in
the order of their significance) after the ON EVERY ROW control block
is executed.
■ You cannot name a TEXT column in a BEFORE GROUP OF or AFTER
GROUP OF clause.
ON LAST ROW
The ON LAST ROW control block specifies the action ACE takes after
processing the last row qualified by the SELECT section, or the last row
retrieved by the READ section.
ON LAST ROW
Control Block
Usage
■ ACE executes the statements in the ON LAST ROW control block after
it executes those in the ON EVERY ROW and AFTER GROUP OF control
blocks.
■ You can use the ON LAST ROW control block to display report totals.
■ When ACE processes the statements in an ON LAST ROW control
block, the values from the last row returned by the SELECT statement
or the last row retrieved by the READ statement are current and can
be used.
PAGE HEADER
The PAGE HEADER control block specifies what information will appear at
the top of each page of the report.
PAGE HEADER
Control Block
Usage
■ The vertical size of the page header is equal to the number of lines
that you specify in the PAGE HEADER control block. The TOP
MARGIN (in the OUTPUT section) affects how close to the top of the
page ACE displays the page header.
■ A FIRST PAGE HEADER control block overrides a PAGE HEADER
control block on the first page of a report.
■ You cannot use the SKIP TO TOP OF PAGE statement in a PAGE
HEADER control block.
■ If you use an IF THEN ELSE statement in a PAGE HEADER control
block, the number of lines displayed by the PRINT and SKIP state-
ments following the THEN keyword must be equal to the number of
lines displayed by the PRINT and SKIP statements following the ELSE
keyword.
■ If you use a FOR or WHILE statement that contains a PRINT statement
in a PAGE HEADER control block, you must terminate the PRINT
statement with a semicolon. The semicolon suppresses any
NEWLINE (RETURN) characters in the loop, keeping the number of
lines in the header constant from page to page.
■ You cannot use a PRINT FILE statement to read and display text from
a file in a PAGE HEADER control block.
PAGE TRAILER
The PAGE TRAILER control block specifies what information will appear at
the bottom of each page of the report.
PAGE TRAILER
Control Block
Usage
■ The vertical size of the page trailer is equal to the number of lines that
you specify in the PAGE TRAILER control block. The BOTTOM
MARGIN (in the OUTPUT section) affects how close to the bottom of
the page ACE displays the page trailer.
■ You cannot use the SKIP TO TOP OF PAGE statement in a PAGE
TRAILER control block.
■ If you use an IF THEN ELSE statement in a PAGE TRAILER control
block, the number of lines displayed by the PRINT and SKIP state-
ments following the THEN keyword must be equal to the number of
lines displayed by the PRINT and SKIP statements following the ELSE
keyword.
■ If you use a FOR or WHILE statement that contains a PRINT statement
in a PAGE TRAILER control block, you must terminate the PRINT
statement with a semicolon. The semicolon suppresses any
NEWLINE (RETURN) characters in the loop, keeping the number of
lines in the trailer constant from page to page.
■ You cannot use the PRINT FILE statement to read and display text
from a file in a PAGE TRAILER control block.
■ You can use the PAGENO expression in a PRINT statement within a
PAGE TRAILER control block to display the page number automati-
cally at the bottom of every page.
Statements
The format control blocks determine when ACE takes an action, while the
statements determine what action ACE takes.
FOR
The FOR statement defines a loop. It repeatedly executes a simple or
compound statement, incrementing the loop index before each pass through
the loop. Control passes to the first statement following the end of the loop
when the termination condition is satisfied.
STEP expr3
Usage
■ You cannot have a decrementing loop—the value of expr3 must be
positive.
■ If a compound statement follows the DO keyword, you must precede
the compound statement with a BEGIN keyword and follow it with
END.
IF THEN ELSE
This statement defines a conditional branch. It evaluates an expression and
executes specific statements based on the result of the evaluation.
ELSE statement2
IF is a required keyword.
expr is a required expression that determines which, if any, of the state-
ments IF executes.
THEN is a required keyword.
statement1 is a required single statement or compound statement that IF executes
if expr evaluates as true (not equal to zero).
ELSE is an optional keyword.
statement2 is an optional single statement or compound statement that IF
executes if expr evaluates as false (equal to zero).
Usage
■ If a compound statement follows the THEN or ELSE keyword, you
must precede the compound statement with the BEGIN keyword and
follow it with END.
■ You can nest IF THEN ELSE statements to 128 levels.
skip 1 line
let i = 1
end
else
let i = i + 1
LET
The LET statement assigns a value to a declared variable.
,
[ num-expr ]
num-expr
Usage
■ If you assign a value with a fractional part to an INTEGER or
SMALLINT variable, ACE truncates the fractional part.
■ Refer to the descriptions of expressions beginning on page 4-82 for
more information about type conversion.
The following example is from the FORMAT section of the [Link] report:
let i = 1
NEED
This statement causes subsequent display to start on the next page if the
specified number of lines cannot be placed on the current page.
Usage
Use the NEED statement to prevent ACE from separating parts of the report
that you want to keep together on a single page.
PAUSE
This statement causes output to the terminal to pause until you press
RETURN.
PAUSE
"string"
Usage
The PAUSE statement has no effect if you use a REPORT TO filename or a
REPORT TO PRINTER statement in the OUTPUT section.
The following example causes ACE to pause while running the report:
after group of item_num
.
.
.
skip to top of page
pause "Press RETURN to continue"
PRINT
This statement displays information on the screen or as specified in the
OUTPUT section.
PRINT
,
;
expr
Usage
■ Unless you use the optional WORDWRAP keyword, one PRINT
statement displays its output on one line, no matter how many lines
the statement occupies in the report specification.
■ Unless you use the keyword CLIPPED or USING following an
expression, ACE displays an expression so that it occupies a prede-
termined number of spaces.
■ You can name a TEXT column in a PRINT statement. The PRINT
statement acts like a PRINT FILE statement with the TEXT item as a
file.
Figure 4-3
Default Display Widths
DATE 10
SERIAL 11
page header
print "NUMBER",
column 9, "NAME",
column 32, "LOCATION",
column 54, "ZIP",
column 62, "PHONE"
skip 1 line
on every row
print customer_num using "####",
column 9, fname clipped, 1 space, lname clipped,
column 32, city clipped, ", " , state,
column 54, zipcode,
column 62, phone
PRINT FILE
This statement displays the contents of a text file in a report.
Usage
You can use the PRINT FILE statement to include the body of a form letter in
a report that generates custom letters.
SKIP
This statement skips lines in a report.
Usage
You cannot use a SKIP TO TOP OF PAGE statement in a FIRST PAGE HEADER,
PAGE HEADER, or PAGE TRAILER control block.
WHILE
The WHILE statement defines a loop that repeatedly executes a simple or
compound statement while the expression is true. Control passes to the first
statement following the loop when the expression evaluates as false.
Usage
If more than one statement follows the DO keyword, you must precede them
with the BEGIN keyword and follow them with END to create a compound
statement.
Aggregates
Aggregates allow you to summarize information in a report.
COUNT
TOTAL OF expr1
AVERAGE
AVG
MIN
MAX
Usage
■ The WHERE part of an aggregate statement further qualifies rows
that the SELECT section already qualified or that the READ statement
already retrieved. WHERE cannot select rows that were not qualified
by the SELECT section or retrieved by the READ section.
■ Aggregates produce unpredictable results when expr1 or expr2
contains user-defined variables. (See “PARAM” on page 4-20 and
“VARIABLE” on page 4-21.)
skip 1 line
print 4 spaces,
"Shipping charges for the order: ",
ship_charge using "$$$$.&&"
skip 1 line
ASCII
ACE evaluates this expression as a value that you can use as a character. You
can use it to display control characters.
ASCII num-expr
Usage
Do not confuse this keyword with the ASCII keyword used in the DEFINE
section to specify the identifiers and data values of an input file.
The following PRINT statement rings the bell (ASCII value of 7) of your
computer:
print ascii 7
This specification uses the FIRST PAGE HEADER control block to initialize
variables that are used in other control blocks.
.
.
define
variable red_on char(3)
variable red_off char(3)
end
.
.
format
first page header
let red_on =
ascii 9, ascii 11, ascii 1
let red_off =
ascii 9, ascii 11, ascii 0
on every row
.
.
print red_on,
"Your bill is overdue.",
red_off
.
.
Tip: ACE cannot distinguish printable and nonprintable ASCII characters. Be sure to
account for the nonprinting characters when you use the COLUMN expression to
format your page. Because various devices print spaces with control characters differ-
ently, you might have to use trial and error to line up columns when you print
control characters.
CLIPPED
This expression displays the character field that precedes it without any
trailing blanks.
char-expr CLIPPED
Usage
You normally use CLIPPED following a column-name in a PRINT statement.
COLUMN
This expression evaluates to a string of spaces long enough to position the
next item in the designated column.
COLUMN num-expr
Usage
■ ACE calculates the column number by adding the number to the left
margin you set in the OUTPUT section.
■ If ACE has already printed past the column specified by num-expr,
ACE ignores the COLUMN expression.
CURRENT
This expression evaluates as a character string with the value of the current
date and time as supplied by the operating system.
CURRENT
first TO last
The following example prints the current date and time to a precision of
MINUTE:
DATE
This expression evaluates as a character string with a value of today’s date in
the form “Thu Feb 17 1999.”
DATE
Because DATE evaluates as type CHAR, you can use it with subscripts to
express a day, month, date, or year. The following example:
print "Today is ", date[1,3]
DATE()
The DATE function converts the expression with which you call it to type
DATE.
DATE ( date-expr )
Usage
■ The DATE function is typically used to convert date strings to type
DATE.
■ A properly formatted date string is required. The default format is
mm/dd/yy, but this can be changed by way of the environment
variable DBDATE.
DAY( )
The DAY function returns the day of the month when you call it with a type
DATE or DATETIME expression.
DAY ( date-expr )
LINENO
This expression has the value of the line number of the line that ACE is
currently displaying. ACE computes the line number by calculating the
number of lines from the top of the page.
LINENO
Usage
Do not use LINENO within a page header or trailer. LINENO works on the first
page header but does not work on any subsequent pages.
MDY( )
The MDY function returns a type DATE value when you call it with three
expressions that evaluate to integers representing the month, date, and year.
MONTH( )
The MONTH function returns an integer that corresponds to the month (1-12)
of its type DATE or DATETIME argument.
MONTH ( date-expr )
PAGENO
This expression has the value of the page number of the page that ACE is
currently displaying.
PAGENO
Usage
Use PAGENO in a PRINT statement in the PAGE HEADER or PAGE TRAILER
control block to number the pages of a report. (You can also use PAGENO in
other control blocks.)
SPACES
This expression evaluates as a string of spaces. It is identical to a quoted
string of spaces.
num-expr SPACE
SPACES
TIME
This expression evaluates as a character string with a value of the current
time in the form hh:mm:ss.
TIME
TODAY
This expression evaluates as type DATE with a value of the current date as
supplied by the operating system.
TODAY
USING
This expression allows you to format a number or date expression. With a
number expression, you can use USING to line up decimal points, right- or
left-justify numbers, put negative numbers in parentheses, and perform
other formatting functions. With a date expression, USING converts the date
to a variety of formats.
Usage
■ The format string must appear between quotation marks.
■ Although USING is generally used as part of a PRINT statement, you
can also use it with LET.
■ If you attempt to display a number that is too large for a display field,
ACE fills the field with asterisks to indicate an overflow.
* This character fills with asterisks any positions in the display field that
would otherwise be blank.
& This character fills with zeros positions in the display field that would
otherwise be blank.
# This character does not change any blank positions in the display field.
Use this character to specify a maximum width for a field.
< This character causes the numbers in the display field to be left-
justified.
Figure 4-5 shows some sample conversions for December 25, 1999.
Figure 4-5
Results of Date Format Strings
“mmddyy” 122599
“ddmmyy” 251299
“yymmdd” 991225
“yy/mm/dd” 99/12/25
“yy mm dd” 99 12 25
“yy-mm-dd 99-12-25
GLS GLS settings can affect the way the format string in the USING expression is
interpreted for numeric and monetary data. In the format string, the period
symbol ( . ) is not a literal character but a placeholder for the decimal
separator specified by environment variables. Likewise, the comma symbol
( , ) is a placeholder for the thousands separator specified by environment
variables. The $ symbol is a placeholder for the leading currency symbol. The
@ symbol is a placeholder for the trailing currency symbol. Thus, the format
string $$#,###.## will format the value 1234.56 as $1,234.56 in a US English
locale but as DM1.234,56 in a German locale. Note that setting the DBFORMAT
or DBMONEY environment variables override settings in LC variables. Refer
to Appendix C, “Global Language Support,” and the Informix Guide to GLS
Functionality.
The following example prints the balance field using a format string that
allows up to $9,999,999.99 to be formatted correctly:
print "The current balance is ",
23485.23 using "$#,###,##&.&&"
The result of executing this PRINT statement with the value 23,485.23 follows:
The current balance is $ 23,485.23
This example fixes the dollar sign. If dollar signs had been used instead of
# characters, the dollar sign would have floated with the size of the number.
It also uses a mix of # and & fill characters. The # character provides blank fill
for unused character positions, while the & character provides zero filling.
This format ensures that even if the number is zero, the positions marked
with & characters appear as zeros, not blanks.
The tables on the following pages illustrate the results of various combina-
tions of data and USING format strings.
"#####" 0 bbbbb
"&&&&&" 0 00000
"$$$$$" 0 bbbb$
"*****" 0 *****
"<<<,<<<" 12 12
"##,###" 12 bbbb12
"##,###" 1 bbbbb1
"##,###" -1 bbbbb1
"##,###" 0 bbbbbb
"&&,&&&" 12 000012
"&&,&&&" 1 000001
"&&,&&&" -1 000001
"&&,&&&" 0 000000
"$$,$$$" 12 bbb$12
"$$,$$$" 1 bbbb$1
"$$,$$$" 0 bbbbb$
"**,***" 12 ****12
"**,***" 1 *****1
"**,***" 0 ******
"##,###.##" -1 bbbbb1.00
WEEKDAY( )
The WEEKDAY function returns an integer that represents the day of the week
when you call it with a type DATE or DATETIME expression.
WEEKDAY ( date-expr )
WORDWRAP
This expression displays the character field that precedes it on multiple lines
with lines broken between words at temporary left and right margins.
char-expr WORDWRAP
Usage
■ The temporary left margin is the current printing column. The
contents of char-expr are displayed on as many lines as necessary
between the temporary left and right margins.
■ Line breaks are positioned to avoid breaking words where possible.
■ A line break is forced where the data contains a line feed (ASCII 10),
a return (ASCII 13), or a combination of the two.
YEAR( )
The YEAR function returns an integer that represents the year when you call
it with a type DATE or DATETIME expression.
YEAR ( date-expr )
User-Menu
5
In This Chapter . . . . . . . . . . . . . . . . . . . . 5-3
Accessing a Menu . . . . . . . . . . . . . . . . . . . 5-4
Using a Menu Within INFORMIX-SQL . . . . . . . . . . 5-4
■ Submenus
■ INFORMIX-SQL programs (PERFORM, for example)
■ Other programs or sets of programs in your software library
■ Operating system utilities
■ Forms or reports
Use a special PERFORM screen form to create or alter a menu structure. Two
special tables hold the menus, text, and command references for each menu
option in the menu structure.
You can create one user-menu for each database. You cannot create a user-
menu without specifying a database. The options in a user-menu, however,
do not have to refer to any particular database.
A user-menu cannot exist separately from a database. If you want to keep the
user-menu apart from your working databases, create a database that
contains only menu data.
User-Menu 5-3
Accessing a Menu
Accessing a Menu
You can access a menu from the INFORMIX-SQL Main menu or from the
operating-system command line. The next section describes the use of the
User-menu option on the INFORMIX-SQL Main menu. Appendix G explains
how to access a user-menu directly from the operating-system command
line.
3. Select the Run option on the USER-MENU menu. The Main menu of
the USER-MENU for the stores7 database displays, as Figure 5-2 on
page 5-5 shows.
Figure 5-2
The Main Menu of the stores7 User-Menu
1. FORMS
2. REPORTS
3. QUERIES
4. TABLE DEFINITIONS
5. UTILITIES
4. Select a menu option by typing the number to the left of the desired
option or positioning the highlight on the option with the Arrow
keys. Press RETURN. INFORMIX-SQL executes the option you select.
5. Type e to exit a menu. If you type e from the demonstration database
menu, the INFORMIX-SQL USER-MENU menu displays.
User-Menu 5-5
Designing a Menu
Designing a Menu
You can have up to 19 levels of menus in the user-menu structure and up to
28 options on each menu.
Most screens can accommodate 14 single-spaced menu lines. Each menu line
can display 2 options of up to 33 characters of text in each option. If the text
for each option on a menu does not exceed 33 characters, you can display up
to 14 double-spaced menu options (2 options per line) or 28 single-spaced
menu options (2 options per line). If the text for an option is longer than 33
characters, it requires an entire line, reducing the total number of options
available for that menu.
■ FORMS
■ REPORTS
■ QUERIES
■ TABLE DEFINITIONS
■ UTILITIES
Each option on the Main menu calls a menu, and each option on a menu
performs an action. A design outline for the user-menu included with the
stores7 database might look like this:
WEST COAST WHOLESALERS, INC.
2. RUN REPORTS
1. RUN CUSTOMER REPORT
2. RUN REPORT ON CUSTOMER BY DESIGNATED STATE
3. RUN CUSTOMER MAILING LABELS
4. RUN MATRIX REPORT ON MONTHLY SALES
5. DISPLAY REPORT 1 SPECIFICATION
6. DISPLAY REPORT 2 SPECIFICATION
7. DISPLAY REPORT 3 SPECIFICATION
8. DISPLAY REPORT 4 SPECIFICATION
5. UTILITY MENU
1. DISPLAY DATE AND TIME
2. CHECK CUSTOMER TABLE
3. UNLOAD CUSTOMER TABLE
User-Menu 5-7
Creating a Menu
Creating a Menu
The first step in creating a menu is to access the PERFORM program with the
menuform screen form. The second step is to enter data through this screen
form.
The menuform form is a special PERFORM screen form that you use only to
create or to modify a user-menu. You can enter, change, and remove menu
information with the form, but you cannot change the appearance of the
screen form itself, and you cannot run FORMBUILD on it.
Menu Name: [ ]
Menu Title: [ ]
--------------------------SELECTION SECTION--------------------------------
Selection
Text:
Selection
Action:
■ The sysmenus table stores information about each menu in the user-
menu. This information includes the Menu name (used by
INFORMIX-SQL to identify the menu), and the Menu title (text that
you want to appear when the menu displays).
■ The sysmenuitems table stores information about the options on
each menu. This information includes the following:
❑ The option number
❑ The option type (program, report, form, INFORMIX-SQL
command file, script menu, or menu)
❑ The option title (text that appears on the screen)
❑ The action the option specifies (execute a program, report, form,
or script menu, or call an INFORMIX-SQL command file or a
menu). A script menu allows the user to run multiple actions in
sequence for a single item. Script menus are described in
“Creating a Script Menu” on page 5-25.
The first person to press Modify from the USER-MENU menu creates both
tables. The creator of the sysmenus and sysmenuitems tables is also the
owner of those tables. Ownership is important when an ANSI-compliant
database is created because, though anyone can run the user-menu, only the
owner of the tables can modify the menu items. Any other user who tries to
modify the menu items receives an error message.
User-Menu 5-9
Entering Menu Data
-------------------------SELECTION SECTION--------------------------------
Selection
Text:
Selection
Action:
The following table shows the information for the Main menu and its
options, which are stored in the sysmenus table in the stores7 database.
forms FORMS
reports REPORTS
utilities UTILITIES
Second, you enter data for each option of each menu in the fields on the lower
half of the screen (the fields associated with the sysmenuitems table).
You must make an entry in the sysmenus table before you make entries for a
menu option in the sysmenuitems table. This step is necessary because
INFORMIX-SQL checks when you enter data in the sysmenuitems table to
make sure that menus cited in that table exist in the sysmenus table.
For example, the complete entry for option 1 on the Main menu is shown in
this screen.
-------------------------SELECTION SECTION--------------------------------
Selection
Text: [FORMS ]
Selection
Action: [forms ]
In this instance, the Selection Action (forms) is the name of a menu (corre-
sponding to Selection Type M). Information about the FORMS menu must be
entered into the sysmenus table before you complete the entry for option 1.
User-Menu 5-11
Entering Menu Data
Figure 5-4
Data in the sysmenuitems Table
mailinglabels 2 display output file from mailing labels report P type [Link]
query1 1 display SQL syntax for query menu choice 1 P type cust_nme.sql
query2 1 display SQL syntax for query menu choice 2 P type cust_row.sql
query3 1 display SQL syntax for query menu choice 3 P type [Link]
query4 1 display SQL syntax for query menu choice 4 P type view_c.sql ;
type view_s.sql ;
type view_d.sql
query5 1 display SQL syntax for query menu choice 5 P type [Link] ;
type [Link]
User-Menu 5-13
Steps for Entering Your Own Data
utility3 1 display SQL syntax for utility menu choice 3 P type u_cust.sql
8. Select the Add option. Enter the Selection Number, Selection Type,
Selection Text, and Selection Action data for the first option on the
Main Menu. Press ESCAPE when you finish entering data about the
first menu option. If there is a second option to the Main Menu, select
Add and enter data about that option. Press ESCAPE when you
finish.
Repeat this step until you have entered data for each option on the
Main Menu.
9. Type m to call the master table again. Use the Query option to locate
and display the Menu Name and Menu Title data for your next
menu. Type d to display the detail table joined to the current row of
the master table.
10. Enter the Selection Number, Selection Type, Selection Text, and
Selection Action data for the first option on this menu. Press ESCAPE
when you finish entering data. Repeat this step for each option in this
menu.
11. Repeat steps 9 and 10 to enter data for the remaining menu options.
When you have entered data for all the options in each menu, the
menu is complete. Select the Exit option to leave PERFORM and
return to the USER-MENU menu.
12. Select the Run option on the USER-MENU menu to run the new
menu.
User-Menu 5-15
Modifying a Menu
Modifying a Menu
You change a user-created menu in the same way you create one. Select the
User-menu option from the INFORMIX-SQL Main menu. Then select the
Modify option on the USER-MENU menu. Use the PERFORM options to
modify the menu entries in the MENUFORM screen form.
MENU NAME
INFORMIX-SQL uses the entry in the Menu Name field to find the menu you
want when you make a selection that calls another menu. The menu name is
used only by INFORMIX-SQL and never displays on a screen.
Usage
■ The menu name must follow the standard rules for identifiers. It can
be from 1 to 18 characters long; the first character must be a letter;
and you can use numbers, letters, and underscores (_) for the rest of
the name.
■ The top-level menu must be named main in all lowercase letters.
The Menu Name entry for the Main menu must be main, as shown in the
following screen.
Menu Title: [ ]
-------------------------SELECTION SECTION--------------------------------
Selection
Text:
Selection
Action:
User-Menu 5-17
MENU TITLE
MENU TITLE
Use this field to enter the text INFORMIX-SQL displays at the top of the menu.
Usage
The brackets on the screen show the maximum length of the text. It can
contain any number of words that fit within the brackets.
-------------------------SELECTION SECTION--------------------------------
Selection
Text:
Selection
Action:
SELECTION NUMBER
Use the Selection Number field to enter the option number you want to
appear to the left of each menu item on the screen.
Usage
■ INFORMIX-SQL displays the menu items in numbered order. The user
selects items by number.
■ The total number of options you can have in one menu depends on
two factors: the number of lines your screen can hold and the length
of the menu titles you enter. Most screens can accommodate 14
single-spaced menu lines, and each menu line can display 2 options
of up to 33 characters. If the text for each option on a menu does not
exceed 33 characters, you can display up to 14 double-spaced menu
options (2 options per line) or 28 single-spaced menu options
(2 options per line). If the text for an option is longer than 33
characters, it requires an entire line, reducing the total number of
options available for that menu.
The Selection Number entry for an option on the REPORTS menu follows.
-------------------------SELECTION SECTION--------------------------------
Selection
Text: [RUN CUSTOMER MAILING LABELS ]
Selection
Action: [mailinglabels ]
User-Menu 5-19
SELECTION TYPE
SELECTION TYPE
Use the Selection Type field to specify the type of action an option performs.
You can indicate that an option runs a form or report; calls a menu; executes
an INFORMIX-SQL command file, a program, or an operating system
command; or invokes a script menu.
The following options are available for the Selection Type field.
Option Purpose
F Runs a form
R Runs a report
M Calls a menu
Usage
■ The entry in the Selection Type field must agree with the entry in the
Selection Action field. For example, when the Selection Type is R, the
Selection Action must be the name of a compiled report.
■ You can enter the Selection Type option in either an uppercase or
lowercase letter. INFORMIX-SQL automatically displays it as an
uppercase letter on the screen.
The Selection Type entry for running the clist2 report follows.
-------------------------SELECTION SECTION--------------------------------
Selection
Text: [RUN REPORT ON CUSTOMER BY DESIGNATED STATE ]
Selection
Action: [clist2 ]
The Selection Type entry for running the customer entry form follows.
-------------------------SELECTION SECTION--------------------------------
Selection
Text: [CUSTOMER ENTRY/QUERY FORM ]
Selection
Action: [customer ]
User-Menu 5-21
SELECTION TEXT
SELECTION TEXT
Use the Selection Text field to enter the text you want to appear to the right
of the option number on the screen.
Usage
■ The brackets on the screen show the maximum length of the text
allowed in this field.
■ The length of the selection text affects the total number of options
you can include in a single menu. See the “Usage” section on page
5-19 for more information.
The Selection Text entry for an option on the REPORTS menu follows.
-------------------------SELECTION SECTION--------------------------------
Selection
Text: [RUN CUSTOMER MAILING LABELS ]
Selection
Action: [mailinglabels ]
SELECTION ACTION
Use the Selection Action field to specify the name of the action executed
when the user selects the option indicated in the Selection Type field. You can
enter a compiled form or report specification, an INFORMIX-SQL command
file, a menu, an operating system command, a program, or a script menu.
Usage
■ The entry in the Selection Action field must agree with the entry in
the Selection Type field, as the following table shows.
■ You can enter Q in the Selection Type field and nothing in the
Selection Action field. When the user selects that option,
INFORMIX-SQL calls the Query-language option on the
INFORMIX-SQL Main menu. The user can then enter one or more SQL
statements.
User-Menu 5-23
SELECTION ACTION
■ You can enter an R or F in the Selection Type field and enter nothing
in the Selection Action field. When the user selects this option,
INFORMIX-SQL calls the Report or Form options, respectively, on the
INFORMIX-SQL Main menu.
■ When you finish using the Query-language Report or Form option,
choose the E option to exit. INFORMIX-SQL then returns you to the
USER-MENU menu.
The Selection Action entry used in the demonstration database for running
the clist1 report follows.
-------------------------SELECTION SECTION--------------------------------
Selection
Text: [RUN CUSTOMER REPORT ]
Selection
Action: [clist1 ]
The Selection Type R specifies that a report should be run. The Selection
Action specifies clist1 as the name of the report to be run.
The following list describes the procedure used to create the mailinglabels
script included in the demonstration user-menu. This script runs and
displays customer mailing labels. It is Selection Number 3 on the REPORTS
menu. When the user selects option 3 on the REPORTS menu, the mailing
labels report runs, and the output file displays on the screen.
1. Select the Modify option on the USER-MENU menu. (See the section
“Creating a Menu” on page 5-8.)
2. Type a to select the Add option.
3. Enter reports in the Menu Name field. The script becomes an option
on the REPORTS Menu.
4. Enter REPORTS in the Menu Title field.
5. Press ESCAPE when you finish.
User-Menu 5-25
Creating a Script Menu
The preceding steps show you how to enter the necessary information in the
sysmenus table. The following display shows how the PERFORM screen
appears at this point.
-------------------------SELECTION SECTION--------------------------------
Selection
Text:
Selection
Action:
Row Added
The following steps show how to enter data into the lower half of the screen
(the sysmenuitems table fields):
1. Type d to make the detail table active.
2. Type a to Add.
3. Enter 3 in the Selection Number field. The script becomes the third
choice on the REPORTS menu.
4. Enter S in the Selection Type field. This indicates you will run a script
menu.
5. Enter the following text in the Selection Text field:
RUN CUSTOMER MAILING LABELS
This text appears to the right of the option number on the screen.
6. Enter mailinglabels in the Selection Action field. This is the name
of the script menu you want to run.
7. Press ESCAPE when you finish.
-------------------------SELECTION SECTION--------------------------------
Selection
Text: [RUN CUSTOMER MAILING LABELS
]
Selection
Action: [mailinglabels ]
Row added
You must now enter the actions you want the script to perform and the order
in which you want them to be performed, as follows:
1. Type m for Master to make the sysmenus table active.
2. Type a to select the Add option.
3. Enter mailinglabels in the Menu Name field. This is the name of
the script menu.
4. Enter the following text in the Menu Title field:
run report menu selection 3 and display the output file
Unlike all other user-menu menus, the entry in the Menu Title field
for a script menu does not display on the screen. You can use it as a
Comment line to list the series of actions that comprise the script
menu.
5. Press ESCAPE when you finish.
User-Menu 5-27
Creating a Script Menu
The preceding steps show how to enter the necessary information in the
sysmenus table. The following screen shows how the PERFORM screen
appears at this point.
Menu Title: [run report menu selection 3 and display the output file ]
-------------------------SELECTION SECTION--------------------------------
Selection
Text:
Selection
Action:
Row added
The following steps show how to enter data for each option on the menu into
the lower half of the screen (the sysmenuitems table fields):
1. Type d to make the detail table active.
2. Select the Add option.
3. Enter 1 in the Selection Number field. INFORMIX-SQL executes this
action first.
4. Enter R in the Selection Type field. This runs a report.
5. Enter the following text in the Selection Text field:
run mailing labels report
Unlike other user-menu menus, the entry in the Selection Text field
for a script menu does not display on the screen. You can use it as a
Comment Line to describe the action specified by the entry in the
Selection Type field.
6. Enter mail in the Selection Action field. This is the name of the
compiled report specified by the action.
7. Press ESCAPE when you finish.
Menu Title: run report menu selection 3 and display the output file
-------------------------SELECTION SECTION--------------------------------
Selection
Text: [run mailing labels report ]
Selection
Action: [mail ]
Row added
You enter the second action for the mailinglabels script in a similar fashion
to what you did when you set up the initial action, as follows:
1. Type a for Add.
2. Enter 2 in the Selection Number field. INFORMIX-SQL executes this
action second.
3. Enter P in the Selection Type field. This executes a program.
4. Enter the following text in the Selection Text field:
display output file from mailing labels report
5. Enter type [Link] in the Selection Action field. This is the name
of the operating-system program you want to run.
6. Press ESCAPE when you finish.
User-Menu 5-29
Creating a Script Menu
Menu Title: run report menu selection 3 and display the output file
-------------------------SELECTION SECTION--------------------------------
Selection
Text: [display output file from mailing labels report ]
Selection
Action: [type [Link] ]
Row added
The two actions of running the report and displaying the output file are now
entered as details of the mailinglabels script menu. When the user selects
option 3 on the REPORTS menu, the mailinglabels script menu is selected, the
mailing labels report is run, and the output file displays on the screen.
Use the Selection Type S when you want to run more than one action for a
single menu item.
Examples . . . . . . . . . . . . . . . . . . . . . . 6-33
ACE Example 1 . . . . . . . . . . . . . . . . . . . 6-33
ACE Example 2 . . . . . . . . . . . . . . . . . . . 6-35
PERFORM Example . . . . . . . . . . . . . . . . . 6-36
FUNCTION
You declare a C function in the DEFINE section of the report specification file
using the FUNCTION statement.
FUNCTION
Statement
FUNCTION userfunc
Usage
You can declare several functions at the same time by repeating the keyword
FUNCTION followed by the next function name. Do not include parentheses
after the function name.
You can have PARAM, VARIABLE, and ASCII statements within the DEFINE
section in addition to the FUNCTION statement.
Calling C Functions
The FORMAT section of the report specification file contains one or more of
the following control blocks that determine when ACE takes an action:
Each control block contains one or more statements that tell ACE what action
to take. For more information on the statements that ACE allows, see Chapter
4. In addition to the statements described in Chapter 4, you can use a C
function call with the syntax shown on page 6-7.
userfunc ( )
CALL
expression
CALL is an optional keyword that you must use when the C function does
not return a value. If you omit the CALL keyword, userfunc must
return a value.
userfunc is the name of a C function that you have previously declared in the
DEFINE section.
expression is 1 to 10 expressions, separated by commas.
Usage
An expression can include the following items:
ACE statements are composed of keywords and expressions. You can use a C
function in an expression wherever you can use a constant. When you use a
function in this way you need not use the CALL keyword, but you must make
sure the function returns a value.
IDS If you are connecting to Informix Dynamic Server, you can pass columns of
type VARCHAR, TEXT, or BYTE. You cannot, however, return TEXT or BYTE
values from a C function. ♦
The following control block calls a C function stat that calculates statistics on
the data in the rows that correspond to the order_num order:
after group of order_num
call stat(order_num)
The following control block prints the order number and a value intended to
correlate the total price of each order with the period of time the order has
been outstanding. It calls a C function that computes the logarithm.
on every row
print order_num,
logarithm((total of total_price)/(today - order_date))
The following control block is taken from “ACE Example 1” on page 6-33. It
prints the system date and time at the top of the first page of the report. The
function to_unix sends its string argument to UNIX.
first page header
call to_unix("date")
The .ace extension is optional when you identify the report specification file
for the saceprep command.
You can use C functions in the control blocks in the INSTRUCTIONS section
of a form specification file. You can also use the ON BEGINNING and
ON ENDING control blocks with a function call within the INSTRUCTIONS
section.
CALL
Statement
userfunc ( )
CALL
expression
CALL is an optional keyword that you must use when the C function does
not return a value. If you omit the keyword CALL, userfunc must
return a value.
userfunc is the name by which the C function is referenced in the PERFORM
specification.
expression is a list of 1 to 10 expressions. An expression is defined as follows:
■ A field tag
■ A constant value
■ An aggregate value
■ A C function
■ The keyword TODAY
■ The keyword CURRENT
■ Any combination of the preceding items, combined by using the
arithmetic operators +, -, *, and /.
IDS If you are connecting to Informix Dynamic Server, you can pass columns of
type VARCHAR, TEXT, or BYTE. You cannot, however, return TEXT or BYTE
values from a C function. ♦
■ Give instructions
■ Request a special password
■ Initialize a temporary work file in which to keep a batch of trans-
action records
ON BEGINNING
Block
expression
ON ENDING
Block
expression
■ A constant value
■ An aggregate value
■ A C function
■ The keyword TODAY
■ The keyword CURRENT
■ Any combination of the preceding items, combined by using
the arithmetic operators +, -, *, and /
The .per extension is optional when you identify the form specification file
for the sformbld command.
valueptr funct1();
valueptr funct2();
{
"myfunct1", funct1,
"myfunct2", funct2,
0,0
};
valueptr funct1()
{
.
.
.
/* funct1 takes no arguments
and returns a character string */
.
.
.
strreturn(s, len);
}
2. Before you initialize the required array of ufunc structures, you must
declare your functions. Included in ctools.h is the definition of the
value structure and pointers to that structure, as shown in the
following example:
typedef struct value *valueptr;
typedef struct value *acevalue;
typedef struct value *perfvalue;
The last two pointers are included for compatibility with earlier
releases of ACE and PERFORM. All your functions must be of type
valueptr. If funct1( ) and funct2(arg1, arg2) are your functions,
declare them next:
valueptr funct1();
valueptr funct2();
3. Make the structure declaration and initialization for userfuncs[ ] the
next section of your program. This structure is required so that ACE
and PERFORM can call your functions at run time:
struct ufunc userfuncs[] =
{
"myfunct1", funct1,
"myfunct2", funct2,
0,0
};
The quoted strings, "myfunct1" and "myfunct2", must be the
names of the functions as they appear in the specification file. funct1
and funct2 (which correspond to "myfunct1" and "myfunct2"), are
pointers to the functions as defined within the C program. Note that
the C functions do not need to have the same names that you used in
your specification file. The purpose of the userfuncs array is to make
the connection between these two names. The two zeros at the end of
the array are required as terminators.
4. The last section of the C program is the code for your functions. As
stated earlier, all the functions that you call in ACE or PERFORM must
be declared as returning pointers to a value structure. Also, all
arguments of your functions must be declared type valueptr.
Several macros are included that you can use to return values of type
valueptr. These and other conversion routines are described in
“Passing Values to a C Function” on page 6-16.
Definition Returns
You can determine the data type of arg by checking arg->v_type against a
series of integer constants defined in sqltypes.h.
IDS If you are connecting to Informix Dynamic Server, you can use the VARCHAR
data type as well. You can check arg->v_type against the following in
sqltypes.h.
toint int
tolong long
tofloat double
todouble double
todate long
todecimal dec_t
todatetime dtime_t
tointerval intrvl_t
All these functions require a pointer to a type value structure and return a
value of the type indicated. The todecimal, todatetime, and tointerval
functions each require a second argument, as the following table shows.
If the type conversion is not successful, the global integer toerrno is set to a
negative value; if the conversion is successful, toerrno is set to zero.
Use the appropriate macro even when you want to return an error condition.
Do not use a simple return.
Because strreturn(s,c) returns a pointer to the string s, be sure to define s as a
static or external variable.
IDS If you are connecting to Informix Dynamic Server, you can use the following
macro to return VARCHAR values.
Function Purpose
PF_GETTYPE()
The pf_gettype() function returns the SQL data type and the length of the
display field for a specified field tag.
pf_gettype(tagname, type, len)
char *tagname;
short *type, *len;
tagname is a string containing the field tag that specifies a display field.
type is a pointer to a short integer that describes the data type of the
display field tagname.
len is a pointer to a short integer that is the length of the display field
tagname on the PERFORM screen.
Usage
The options for type follow.
SQLCHAR CHARACTER
SQLSMINT SMALLINT
SQLINT INTEGER
SQLFLOAT FLOAT
SQLSMFLOAT SMALLFLOAT
SQLDECIMAL DECIMAL
SQLSERIAL SERIAL
SQLDATE DATE
SQLMONEY MONEY
SQLDTIME DATETIME
SQLINTERVAL INTERVAL
IDS If you are connecting to Informix Dynamic Server, you can also specify the
following data types.
SQLVCHAR VARCHAR
SQLTEXT TEXT
SQLBYTE BYTE
Return Codes
0 The operation was successful; display field was found.
PF_GETVAL()
If the display field is a character field, pf_getval() obtains the value found in
a display field and the length of the value.
pf_getval(tagname, retvalue, valtype, vallen)
char *tagname, *retvalue;
short valtype, vallen;
tagname is a string containing the field tag that specifies a display field.
retvalue is a pointer to the string, short, long, float, double, decimal,
datetime, or interval structure returned by pf_getval().
vallen is a short integer specifying the length of the string (plus 1 for the
terminating null byte) returned in retvalue, when valtype is
CCHARTYPE. For any other value for valtype, vallen is ignored.
Usage
The parameter retvalue must be a pointer to the variable that contains the
value. A common programming error is to use the variable itself. This results
in a run-time system error and is not detected by the compiler.
CCHARTYPE
CFIXCHARTYPE CHARACTER
CSTRINGTYPE
CINTTYPE INTEGER
CSHORTTYPE SMALLINT
CFLOATTYPE SMALLFLOAT
CDOUBLETYPE FLOAT
CDATETIME DATETIME
CINTERVAL INTERVAL
(2 of 2)
The value given to the parameter valtype determines the type of retvalue. The
parameter valtype need not correspond exactly to the data type of the display
field, but both should be either a number or a character so that PERFORM can
do the proper type conversion.
IDS If you are connecting to Informix Dynamic Server, you can also specify the
following data types for valtype.
CVCHARTYPE SQLVCHAR
CLOCATORTYPE SQLTEXT
SQLBYTES
For VARCHAR values, vallen must contain the number of bytes the value
buffer can hold. For TEXT and BYTE values, if you point retvalue to a loc_t
structure, PERFORM copies the internal locator of loc_t to your structure. ♦
Return Codes
0 The operation was successful; display field was found.
PF_PUTVAL ()
The pf_putval() function puts a value into a PERFORM screen in a specified
display field. The user must have permission to update or to enter data into
the desired destination field.
pf_putval(pvalue, valtype, tagname)
char *pvalue;
short valtype;
char *tagname;
valtype is a short integer indicating the type of the value to which pvalue
points.
tagname is a string containing the field tag that specifies the display field
where the information pointed to by pvalue is placed.
Usage
The pvalue parameter must be a pointer to the variable containing the value.
A common programming error is to use the variable itself. This results in a
run-time system error and is not detected by the compiler.
CCHARTYPE
CFIXCHARTYPE CHARACTER
CSTRINGTYPE
CINTTYPE INTEGER
CSHORTTYPE SMALLINT
CFLOATTYPE SMALLFLOAT
CDOUBLETYPE FLOAT
CDATETIME DATETIME
CINTERVAL INTERVAL
(2 of 2)
If valtype is one of the character types and the display field is a number field,
PERFORM tries to convert valtype. If the conversion is unsuccessful, PERFORM
enters 0 in the display field.
If the type specified is a number field and the display field is character, a
conversion to a string occurs. If the string does not fit in the display field,
PERFORM truncates the display field.
If a number value does not fit in a number display field, PERFORM fills the
field with asterisks.
IDS If you are connecting to Informix Dynamic Server, you can also specify the
following data types for valtype.
CVCHARTYPE SQLVCHAR
CLOCATORTYPE SQLTEXT
SQLBYTES
Use this function with VARCHAR values just as you use it with CHARACTER
values.
If you use this function with TEXT or BYTE data types, pvalue must point to a
loc_t structure. PERFORM requires that the loc_t structure contain exactly the
same information as the loc_t structure corresponding to tagname. For this
reason, refrain from changing anything in your copy of the locator. You can
then use the locator to change the actual value of the TEXT or BYTE data type,
which PERFORM stores in a temporary file.♦
Return Codes
0 The operation was successful; display field was found.
PF_NXFIELD ()
The pf_nxfield() function controls the cursor placement on a PERFORM
screen when you add a new record or update an old record.
pf_nxfield(tagname)
char *tagname;
tagname is a string that contains the field tag for the display field on a
PERFORM screen to which the cursor is sent.
Usage
The following list describes what happens at the different times when you
call pf_nxfield:
Return Codes
0 The operation was successful; display field was found.
PF_MSG()
The pf_msg() function displays a message at the bottom of the screen.
pf_msg(msgstr, reverseflag, bellflag)
char *msgstr;
short reverseflag, bellflag;
Usage
If several calls to pf_msg are invoked at the same time in response to
satisfying several conditions simultaneously, only the last message displayed
is visible to the user.
cperf -m [Link]
After you compile your custom version of sacego or sperform, you can run
reports or forms with the following command line:
custprog specfile
where custprog is the output file of the cace or cperf command, and specfile is
the name of the report or form specification file you compiled using ACEPREP
or FORMBUILD. When using sacego, specify the .arc suffix for specfile; when
using sperform, specify the .frm suffix for specfile.
Examples
This section contains examples of both ACE applications and PERFORM
applications. ACE C functions can be used with PERFORM as well. These
sample programs are delivered with the demonstration database.
ACE Example 1
The following specification file calls a user function to execute a system
command. The program is named a_ex1.ace in the demonstration database.
database
stores
end
define
function to_unix
end
format
first page header
call to_unix("date")
skip 1 line
on every row
print customer_num, 3 spaces,
fname clipped, 1 space, lname
end
valueptr to_unix();
valueptr to_unix(string)
valueptr string;
{
char savearea[80];
system(savearea);
}
ACE Example 2
The following ACE program computes the average and the standard
deviation of the total cost of all the orders in the stores7 demonstration
database. This program is named a_ex2.ace in the demonstration database.
database
stores
end
define
function decsqroot
end
format
on every row
print order_num, t_cost
on last row
skip 1 line
print "The average total order is : ",
(total of t_cost)/count
using "$#####.##"
print "Standard deviation is : ",
decsqroot((total of t_cost*t_cost)/count
- ((total of t_cost)/count)**2)
using "$#####.##"
end
valueptr squareroot();
valueptr squareroot(pnum)
valueptr pnum;
{
double dub;
dec_t dec;
dub = sqrt(dub);
/* return decimal */
decreturn(dec);
}
PERFORM Example
This example demonstrates accessing and displaying the following data from
UNIX:
The following form specification file uses the customer table to let you enter
new customers into the stores7 database. The form also includes two
DISPLAYONLY fields that display the name of the entry clerk and the entry
time. (To include the name of the entry clerk and the entry time in the
database, you would need to add entry clerk and entry time columns to the
customer table, rather than use the DISPLAYONLY fields.)
The cursor moves from the upper left down through the Customer Data by
following the order of the fields listed in the ATTRIBUTES section. After the
Telephone field, the cursor moves to the Owner Name field. When the entry
clerk presses ESCAPE to complete the transaction, PERFORM calls the C
function stamptime().
**************************************************************
* Customer Form *
*============================================================*
* Number :[f000 ] *
* Owner Name :[f001 ][f002 ] *
* Company :[f003 ] *
* Address :[f004 ] *
* [f005 ] *
* City :[f006 ] State:[a0] Zipcode:[f007 ] *
* Telephone :[f008 ] *
**************************************************************
* Entry Clerk :[f009 ] Time Entered :[f010 ] *
**************************************************************
}
tables
customer
attributes
f000 = customer.customer_num, noentry;
f001 = [Link];
f002 = [Link];
f003 = [Link];
f004 = customer.address1;
f005 = customer.address2;
f006 = [Link];
a0 = [Link], default="CA", upshift, autonext;
f007 = [Link], autonext;
f008 = [Link];
f009 = displayonly type char;
f010 = displayonly type char;
instructions
end
The function stamptime(), called by the form specification file when the entry
clerk presses ESCAPE to complete the transaction, follows. In addition to the
special function pf_putval() defined earlier in this section, stamptime() uses
the system functions time(), localtime(), and getlogin(). The login name of
the order taker is obtained from the string function getlogin() and is
displayed in the screen field Entry Clerk.
The system time is decomposed into hours and minutes and then
reconstructed into a string variable displayed in the screen field Time
Entered. PERFORM then writes the record to the customer table, using the
data on the screen.
#include <stdio.h>
#include <time.h>
#include "ctools.h"
valueptr stamptime();
valueptr stamptime()
{
long seconds, time();
char usertime[10], *getlogin();
struct tm *timerec, *localtime();
sprintf(usertime, "%02d:%02d",
timerec->tm_hour, timerec->tm_min);
pf_putval(usertime, CCHARTYPE, "f010");
}
The Demonstration
Database and Examples A
The stores7 demonstration database contains a set of tables that
describe an imaginary business. You can access the data in the
stores7 demonstration database using the sample programs that
appear in this book, as well as through application programs
that are listed in the documentation of other Informix products.
The stores7 demonstration database is not MODE ANSI.
If you list the contents of your current directory, you will see filenames
SE similar to the following ones (if you are using an INFORMIX-SE server, you
will also see a directory named [Link] that contains files for the sample
database.) ♦
[Link] [Link]
Additional forms, reports, and command files are included that are not part
of the examples described in the manuals. These provide further opportu-
nities for practice after you become familiar with the demonstration database
and examples.
You can restore the demonstration database to an original condition (the one
upon which the examples are based) by re-creating the database with the
isqldemo command.
For example, you might want to make a fresh copy of the demonstration
database each time you start a new chapter. The files that make up the
demonstration database are protected so that you cannot make any changes
to the original copy.
screen
{
CUSTOMERS
Company : [f001 ]
First Name: [f002 ] Last Name: [f003 ]
Address : [f004 ]
[f005 ]
Telephone : [f008 ]
}
end
tables
customer
attributes
f000 =
customer_num;
f001 =
company, reverse;
f002 =
fname, comments = "Please enter first name if available";
f003 =
lname;
f004 =
address1;
f005 =
address2;
f006 =
city;
a0 =
state, upshift, autonext, include = ("CA", "OR", "NV", "WA");
comments = "Legal states are CA, OR, NV, or WA";
f007 = zipcode, autonext;
f008 = phone, picture = "###-###-####XXXXXX";
end
screen
{
===============================================================================
CUSTOMER INFORMATION:
Customer Number: [c1 ] Telephone: [c10 ]
Company: [c4 ]
First Name: [c2 ] Last Name: [c3 ]
Address: [c5 ]
[c6 ]
City: [c7 ] State: [c8] Zip: [c9 ]
===============================================================================
ORDER INFORMATION:
Order Number: [o11 ] Order Date: [o12 ]
Stock Number: [i13 ]Manufacturer: [i16]
[manu_name ]
Quantity: [i18 ]
Total Price: [i19 ]
SHIPPING INFORMATION:
Customer P.O.: [o20 ]
end
tables
customer orders
items manufact
attributes
c1 = *customer.customer_num = orders.customer_num;
c2 = fname,
comments = "Please enter initial if available ";
c3 = lname;
c4 = company;
c5 = address1;
c6 = address2;
c7 = city;
c8 = state, upshift, autonext,
include = ("CA","OR","NV","WA");
c9 = zipcode;
c10 = phone, picture = "###-###-####x#####";
o11 = *orders.order_num = items.order_num;
o12 = order_date,
default = today;
i13 = items.stock_num;
i16 = items.manu_code , lookup manu_name = manufact.manu_name,
joining *manufact.manu_code, upshift;
instructions
end
screen
{
========================================================================
========================================================================
CUSTOMER INFORMATION:
Company: [c4 ]
First Name: [c2 ] Last Name: [c3 ]
Address: [c5 ]
[c6 ]
========================================================================
========================================================================
}
screen
{
========================================================================
CUSTOMER NUMBER: [c1 ] COMPANY: [c4 ]
ORDER INFORMATION:
Order Number: [o11 ] Order Date: [o12 ]
SHIPPING INFORMATION:
Customer P.O.: [o20 ] Ship Charge: [d1 ]
}
end
tables
customer items stock
orders manufact
attributes
c1 = *customer.customer_num
= orders.customer_num;
c2 = fname,
comments = "Please enter initial if available";
c3 = lname;
c4 = company, reverse;
c5 = address1;
c6 = address2;
c7 = city;
c8 = state, upshift, autonext,
include = ("CA","OR","NV","WA"),
default = "CA" ;
c9 = zipcode, autonext;
c10 = phone, picture = "###-###-####x####";
o11 = *orders.order_num = items.order_num;
o12 = order_date, default = today, format = "mm/dd/yyyy";
i13 = items.stock_num;
= *stock.stock_num, noentry, noupdate, queryclear;
i16 = items.manu_code, lookup m17 = manufact.manu_name
joining *manufact.manu_code, upshift, autonext;
= *stock.manu_code, noentry, noupdate,
upshift, autonext, queryclear;
s14 = [Link], noentry, noupdate;
s16 = stock.unit_descr, noentry, noupdate;
s15 = stock.unit_price, noentry, noupdate;
i18 = [Link], include = (1 to 50),
comments = "Acceptable values are 1 through 50" ;
i19 = items.total_price;
o20 = po_num, required,
comments = "If no P.O. Number enter name of caller" ;
a = backlog, autonext;
o21 = ship_date, default = today, format = "mm/dd/yyyy";
o22 = paid_date, format = "mm/dd/yyyy";
o23 = ship_instruct;
d1 = displayonly type money;
d2 = displayonly type money;
instructions
let d1 = 0
let d2 = 0
end
database
stores7
end
output
left margin 2
end
select
customer_num,
fname,
lname,
company,
city,
state,
zipcode,
phone
from
customer
order by
city
end
format
page header
print "NUMBER",
column 9, "NAME",
column 32, "LOCATION",
column 54, "ZIP",
column 62, "PHONE"
skip 1 line
on every row
print customer_num using "####",
column 9, fname clipped, 1 space, lname clipped,
column 32, city clipped, ", " , state,
column 54, zipcode,
column 62, phone
on last row
skip 1 line
print "TOTAL NUMBER OF CUSTOMERS:",
column 30, count using "##"
end
database
stores7
end
define
variable thisstate char(2)
end
input
prompt for thisstate using
"Enter state (use UPPER CASE) for which you wish a customer list: "
end
output
left margin 0
end
select
customer_num,
fname,
lname,
company,
city,
state,
zipcode,
phone
from
customer
where
state matches $thisstate
order by
zipcode,
lname
end
format
page header
print "NUMBER",
column 9, "NAME",
column 32, "LOCATION",
column 54, "ZIP",
column 62, "PHONE"
skip 1 line
on every row
print customer_num using "####",
column 9, fname clipped, 1 space, lname clipped,
column 32, city clipped, ", " , state,
column 54, zipcode,
column 62, phone
on last row
skip 2 lines
print "Number of customers in ",thisstate, " is ", count using "<<<<&"
end
database
stores7
end
select *
from customer
order by zipcode, lname
end
format
on every row
print fname, lname
print company
print address1
print address2
print city, ", " , state, 2 spaces, zipcode
skip 2 lines
end
database
stores7
end
output
top margin 0
bottom margin 0
left margin 0
page length 9
report to "labels"
end
select
fname, lname,
company,
address1,
address2,
city, state, zipcode
from customer
order by zipcode, lname
end
format
on every row
if (city is not null) and
(state is not null) then
begin
print fname clipped, 1 space, lname
print company
print address1
if (address2 is not null) then
print address2
print city clipped, ", " , state,
2 spaces, zipcode
skip to top of page
end
end
database
stores7
end
define
variable name char(75) {holds first and last names}
variable cstzp char(75) {holds city, state, and zip}
variable array1 char(80) {Array for name line}
variable array2 char(80) {Array for street line}
variable array3 char(80) {Array for city, state, and zipcode}
variable start smallint {start of current label in array}
variable finish smallint {end of current label in array}
variable l_size smallint {label width}
variable white smallint {spaces between each label}
variable count1 smallint {number of labels across page}
variable i smallint {label counter}
end
input
prompt for count1 using "Number of labels across page? [1-3] "
end
output
top margin 0
bottom margin 0
left margin 0
report to "[Link]"
end
select
*
from
customer
order by
zipcode
end
format
first page header {Nothing is displayed in this
control block. It just
on every row
let name = fname clipped, 1 space, lname
let cstzp = city clipped,
", ",
state,
2 spaces, zipcode
let finish = (i * l_size) + white
{This section assigns names, }
let start = finish - l_size
{addresses, and zip codes to }
let array1[start, finish] = name
{arrays 1, 2, 3 until }
let array2[start, finish] = address1
{i = the number of labels }
let array3[start, finish] = cstzp
{across a page. }
if i = count1 then
begin
print array1 clipped {Print the stored addresses.}
print array2 clipped {Use clipped to remove trailing}
print array3 clipped {spaces for quicker printing.}
skip 1 line
let i = 1
end
else
let i = i + 1
on last row
if i > 1 then {Print the last set of addresses}
begin {if there were any left.}
print array1 clipped
print array2 clipped
print array3 clipped
end
end
Order Specification - 1 }
database
stores7
end
output
report to "ordlist1"
end
select
orders.order_num ordnum,
order_date, customer_num,
po_num, ship_date, ship_charge,
paid_date,
order by ordnum
end
format
on every row
print stock_num using "###", column 20,
manu_code, column 28, quantity using "###",
column 38, total_price using "$$$,$$$.&&"
end
Order Specification - 2 }
database
stores7
end
output
left margin 0
report to "ordlist2"
end
select
stock.stock_num, stock.manu_code,
description, unit_price
end
format
on every row
print snum using "###", column 10, manu_code,
column 18, description clipped, column 38,
skip 1 line
print 4 spaces,
"Shipping charges for the order: ",
ship_charge using "$$$$.&&"
skip 1 line
end
Order Specification - 3 }
database
stores7
end
define
variable begin_date date
variable end_date date
end
input
prompt for begin_date using
"Enter beginning date for report: "
prompt for end_date using
"Enter ending date for report: "
end
output
left margin 0
report to "ordlist3"
end
select
format
on last row
skip 1 line
print column 15, "======================================================"
skip 2 lines
print "Total Amount of orders: ", total of
total_price using "$$$$,$$$,$$$.&&"
page trailer
print column 28, pageno using "page <<<<"
end
Setting Environment
Variables B
Various environment variables affect the functionality of your
Informix products. You can set environment variables that
identify your terminal, specify the location of your software, and
define other parameters.
Tip: The first time you set an environment variable in a shell or configuration file,
before you work with your Informix product, you should log out and then log back in,
“source” the file (C shell), or use “.” to execute an environment-configuration file
(Bourne or Korn shell). This allows the process to read your entry.
After one or more Informix products have been installed, enter the following
command at the system prompt to view your current environment settings:
BSD UNIX: env
When Bourne-shell example settings are shown in this chapter, the Korn shell
(a superset of the Bourne shell) is implied as well. Korn-shell syntax allows
for a shortcut, as Figure B-1 shows.
The following diagram shows how the syntax for setting an environment
variable is represented throughout this chapter. These diagrams indicate the
setting for the C shell; for the Bourne or Korn shell, follow the syntax in
Figure B-1.
For more information on how to read syntax diagrams, see the introduction.
To unset most of the environment variables that this chapter shows, enter the
following command:
C shell: unsetenv ABCD
IDS
■ The default Informix Dynamic Server or INFORMIX-SE database
server for explicit or implicit connections is indicated by an entry in
SE the $INFORMIXDIR/etc/sqlhosts file (INFORMIXSERVER). ♦
■ The default directory for message files is $INFORMIXDIR/msg
(DBLANG unset and LANG unset).
SE ■ If you are using INFORMIX-SE, the target or current database is in the
current directory (DBPATH).
Rules of Precedence
When an Informix product accesses an environment variable, normally the
following rules of precedence apply:
Environment Variables
Important: Most of the environment variables you need are described in the
“Informix Guide to SQL: Reference” and the “Informix Guide to GLS Function-
ality.” This appendix covers only environment variables not described in those
manuals.
DBFORM
The DBFORM environment variable specifies the subdirectory of
$INFORMIXDIR (or full pathname) in which the menu form files for the
currently active language reside. ($INFORMIXDIR means “the name of the
directory referenced by the environment variable INFORMIXDIR”). Menu
form files provide a set of language-translated menus to replace the standard
INFORMIX-SQL menus. Menu form files have the suffix .frm. Menu form files
are included in language supplements, which contain instructions specifying
where the files should be installed and what DBFORM settings to specify.
Usage
If DBFORM is not set, the default directory for menu form files is
$INFORMIXDIR/forms. The files should be installed in a subdirectory under
the forms subdirectory under $INFORMIXDIR. For example, French menu
files could be installed in $INFORMIXDIR/forms/french or in
$INFORMIXDIR/forms/fr.88591. The English language version will normally
be installed in $INFORMIXDIR/forms or $INFORMIXDIR/forms/english.
Non-English menu form files should not be installed in either of the locations
where English files are normally found.
Figure B-2 illustrates the search method employed for locating message files
for a particular language (where the value set in the DBFORM environment
variable is indicated as $DBFORM).
Figure B-2
$INFORMIXDIR/forms/$DBFORM/ Directory Search
Order, Depending
on $DBFORM
$INFORMIXDIR/$DBFORM/
search
order
$INFORMIXDIR/forms/
$INFORMIXDIR/forms/english/
If the LANG variable is set, and DBFORM is not, the search order changes, as
Figure B-3 shows.
Figure B-3
$INFORMIXDIR/forms/$LANG/ Directory Search
Order, Depending
on $LANG
$INFORMIXDIR/$LANG/
search
order
$INFORMIXDIR/forms/
$INFORMIXDIR/forms/english/
If both DBFORM and LANG are set, LANG is ignored in establishing search
order.
For example, you can store the set of menu form files for the French language
in $INFORMIXDIR/forms/french as follows:
setenv DBFORM french
DBFORMAT
The Informix-defined DBFORMAT environment variable specifies the default
format in which the user inputs, displays, or prints values of the following
data types:
■ DECIMAL
■ FLOAT
■ SMALLFLOAT
■ INTEGER
■ SMALLINT
■ MONEY
setenv DBFORMAT : : :
front thousands decimal back
front is the leading currency symbol. The front value is optional. The null
string, represented by “*”, is allowed, and means that the leading
currency symbol is not applicable.
thousands is a list of one or more characters that determine the possible thousands
separator. The user can use any of the specified characters as the
thousands separator when inputting values. The values in the list are
not separated by spaces or other characters. INFORMIX-SQL uses the
first value specified as the thousands separator when displaying the
output value.
You can specify any characters for the thousands separator except the
following:
■ Digits
■ <, >, |, ?, !, =, [, ]
If you specify the * character, INFORMIX-SQL omits the thousands
separator. The thousands value is optional. The default value is the *. A
blank space can be the thousands separator and is used for this purpose
in some locales.
In versions prior to 6.0, the colon symbol (:) was not allowed as a
thousands separator. In version 6.0, the colon symbol is permitted, but
must be preceded by a backslash (\) symbol, as in the specification
:\::.:DM.
(1 of 2)
decimal is a list of one or more characters that determine the possible decimal
separators. The user can use any of the specified characters as the
decimal separator when inputting values. INFORMIX-SQL uses the
first value specified as the decimal separator when displaying the
output value.
You can specify any characters except the following characters:
■ Digits
■ <, >, |, ?, !, =, [, ]
■ Any characters specified for the thousands value
The decimal value is optional. Specification of an asterisk symbol in the
decimal position will cause displayed values not to have a decimal
separator.
The colon symbol is permitted as a decimal separator but must be
preceded by a backslash (\) symbol in the DBFORMAT specification.
back is a value that determines the trailing currency symbol. The back value
is optional.
(2 of 2)
You must specify all three colons in the syntax. Enclosing the DBFORMAT
specification in a pair of single quotes is suggested to prevent the shell from
interpreting any of the characters.
Usage
The setting in DBFORMAT directly specifies the leading and trailing currency
symbol, and the numeric and decimal separators. It adds the currency
symbol and changes the separators displayed on the screen in a monetary or
numeric field, and in the default format of a PRINT statement. For example,
if DBFORMAT is set to:
*:.:,:DM
DM stands for deutsche marks. In the case of a screen form, values input by
the user are expected to contain commas, not periods, as decimal separators
if this DBFORMAT string has been specified.
The setting in DBFORMAT also affects the way format strings in the FORMAT
attribute in ACE and the USING clause in PERFORM are interpreted. In these
format strings, the period symbol (.) is not a literal character but a placeholder
for the decimal separator specified by DBFORMAT. Likewise, the comma
symbol ( , ) is a placeholder for the thousands separator specified by
DBFORMAT. The dollar sign is a placeholder for the leading currency
symbol. The at-sign (@) symbol is a placeholder for the trailing currency
symbol. Figure B-4 illustrates the results of different combinations of
DBFORMAT setting and format string on the same value.
Figure B-4
Illustration of the Results of Different DBFORMAT Settings and Format Strings
When money values are converted to character strings using the LET
statement in ACE, both the default conversion and the conversion with a
USING clause will insert the DBFORMAT-defined separators and currency
symbol into the created strings.
DBTEMP
Set the DBTEMP environment variable to specify the full pathname of the
directory into which you want INFORMIX-SE to place its temporary files. You
need not set DBTEMP if the default, /tmp, is satisfactory.
For the creation of temporary tables, if DBTEMP is not set, the temporary
tables are created in the directory of the database (that is, the .dbs directory).
Code sets are based on logical characters, independent of the font that a
display device uses to represent a given character. The size or font in which
INFORMIX-SQL displays a given character is determined by factors
independent of the code set. (But if you select, for example, a font that
includes no representation of the Chinese character for “star,” then only
whitespace will be displayed for that character, until you specify a font that
supports it.)
Collation Order
Collation order is the sequence in which character strings are sorted. Database
servers can support collation in either code-set order (the sequence of code
points) or localized order (some other predefined sequence). For details of
localized collation, see the Informix Guide to GLS Functionality.
INFORMIX-SQL supports only code-set order; the database server, rather than
INFORMIX-SQL, must do the sorting if you require localized collation of data
values in NCHAR or NVARCHAR columns of the database.
Locales
For INFORMIX-SQL (and for Informix database servers and connectivity
products), a locale is a set of files that specify the linguistic and cultural
conventions that the user expects to see when the software runs. A locale can
specify these:
NCHAR Sorts in the order of the user locale. Available only by way of SQL CREATE TABLE
NVARCHAR Sorts in the order of the user locale. Available only by way of SQL CREATE TABLE
DATE Separator symbol and order of month, day, and year depends on the value in
DBDATE. Display of language-specific month and day names depends on instal-
lation of message files, whose location is referenced by DBLANG.
DATETIME Display of language-specific month and day names depends on the installation of
message files, whose location is referenced by DBLANG
Figure C-2
Impact of GLS Support on Menu Options and Keywords
LOAD The LOAD statement expects incoming text files to be in the format
specified by the GLS and Informix locale settings and environment
variables
UNLOAD Text files produced by an UNLOAD are output in the format specified
by GLS and Informix GLS and Informix locale settings and environment
variables but without thousands separators
CREATE TABLE, CHAR and VARCHAR columns defined in non-English locales are
ALTER TABLE created as NCHAR and NVARCHAR. CHAR and VARCHAR columns
that behave as CHAR and VARCHAR in these environments can only be
created by way of the SQL CREATE TABLE and ALTER TABLE
statements
FORMAT Same as USING except that FORMAT does not support currency
symbols
ORDER BY, MATCHES, Comparisons of character values are based on collation sequences
WHILE, INCLUDE, defined by the COLLATE category
and IF
UPSHIFT and DOWNSHIFT Translations between upper and lowercase are specified by the CTYPE
category
DATE The date displayed contains month and day names specified by the
message files pointed to by DBLANG
CALL (to C function) Called C functions can include locale-specific characters in identifiers, if
the C compiler can support these
■ Names of identifiers
■ Values of CHAR and VARCHAR variables and formal arguments
■ Characters within TEXT blobs
■ Message text, quoted strings, and values returned by functions
■ Text within comments, forms, menus, and output from reports
The default environment for INFORMIX-SQL is based on the ASCII code set of
128 characters, as listed in Appendix E, “The ASCII Character Set.” Each of
these encoded values (or code points) requires seven bits of a byte to store each
of the values 0 through 127, representing the letters, digits, punctuation, and
other logical characters of ASCII. Because each ASCII character can be stored
within a single byte, ASCII is called a single-byte character set. All other
character sets that INFORMIX-SQL can support must include ASCII as a subset.
You can enter, edit, and display valid characters from the code set of the client
locale in INFORMIX-SQL. Whether a given character from a non-English code
set is printable or nonprintable depends on the client locale.
SQL Identifiers
SQL identifiers are the names of database entities, such as table and column
names, indexes, and constraints. The first character must be an alphabetic
character, as defined by the locale, or an underscore (= ASCII 95) symbol. You
can use alphanumeric characters and underscores ( _ ) for the rest of the SQL
identifier. Most SQL identifiers can be up to 18 bytes in length. What
characters are valid in SQL identifiers depends on the locale of the database
server (see “Client Locales and Server Locales” on page C-15). Neither single-
byte nor multibyte whitespace characters can appear in SQL identifiers.
UNIX
SE
For INFORMIX-SE database servers, whether non-English characters are
permitted in the names of databases, tables, or log files depends on whether
the operating system permits such characters in filenames. ♦
Input and output filenames cannot be localized. Only ASCII characters are
valid in input and output pathnames or filenames.
Collation Sequence
The collation (sorting) sequence is implied by the code-set order in the files that
define the client locale. (Any collating that is specified by the COLLATE
category of the client locale is ignored.) Collation in SQL operations (where
the database server uses its own collation sequence) depends on the data
type and on the server locale (which can specify a localized order of
collation). It is possible for INFORMIX-SQL and the database server to use a
different collating sequence, or for INFORMIX-SQL to connect to two or more
servers that use different collating sequences. The collation sequence can
affect the value of Boolean expressions that use relational operators, and the
sorted order of rows in queries and in reports.
Character string values can include multibyte characters that are supported
by the client locale in contexts like these:
Logical Characters
Within a single-byte locale, every character of data within character-string
values requires only a single byte of memory storage, and a single character
position for display by a character-mode device.
Partial Characters
The most important motivation for distinguishing between logical characters
and their component bytes is the need to avoid partial characters. These are
fragments of multibyte characters. Entering partial characters into the
database implies corruption of the database, and risks malfunction of the
database server.
retrieved three data values from col1 (where col1 is a CHAR, NCHAR,
NVARCHAR, or VARCHAR column); here the first line is not a data value but
indicates the alignment of bytes within the substrings:
AA 2BB 2AA becomes " s1B s1"
ABA 2C 2AA becomes "A 2s1"
A 2B 2CABC becomes "B 2C"
*.cm
gls cm3
*.cmo
*.lc
en_us
lc11
*.lco
---
en_us 0333 *.iem
msg
---
$INFORMIXDIR etc (similar to msg subdirectory)
en_us 0333 *
sql
demo
---
---
Language Supplements
Use of INFORMIX-SQL with some non-English languages might require an
Informix language supplement specific to the conventions of the country or
language. Language supplements are currently required, for example, for
Informix database servers to support each of the following East Asian
languages.
Language supplements for these East Asian languages include locale files,
translated message files, and translated menu files. Localized versions of
INFORMIX-SQL for East Asian locales (for example, Japanese INFORMIX-SQL)
will include the relevant files. See the release notes for additional
information.
“Latin” denotes what is also called the “Roman” alphabet in U.S. English. In
any locale, INFORMIX-SQL requires at least one font that supports the code
set.
Specifying Locales
INFORMIX-SQL requires that locales be specified, through environment
variables and settings in locale files, on UNIX systems that support the
database server.
For details about configuring UNIX systems for global language support and
for an example of non-English locale files, see the Informix Guide to GLS
Functionality. For additional information about setting environment
variables, see also “Configuring the Language Environment” on page C-16.
Important: Except for DBFORMAT, all the environment variables that are described
in the sections that follow apply to Informix database servers.
DBAPICODE
This environment variable specifies the name of a mapping file for peripheral
devices (for example, a keyboard, a display terminal, or a printer) whose
character set is different from that of the database server.
DB_LOCALE
This environment variable specifies the locale of the database to which
INFORMIX-SQL is connected. The format for setting DB_LOCALE is
DB_LOCALE=<locale>.
CLIENT_LOCALE
This environment variable specifies the locale of the (input) source code and
the compiled code (to be generated). This is also the locale of the error files (if
any) and the intermediate files. The format of CLIENT_LOCALE is the same
as that of DB_LOCALE:
■ The characters that reach the user interface (the non-ASCII
characters) must be in the CLIENT_LOCALE.
■ If DB_LOCALE is invalid, either because of incorrect formatting
or specifying a locale that does not exist, an error is issued.
■ The DB_LOCALE and CLIENT_LOCALE settings need to be
compatible, meaning there should be proper code-set conversion
tables between them. Otherwise, an error is generated.
■ Collation follows the code-set order of CLIENT_LOCALE, except in
SQL statements (where the database server uses its own collation
sequence). Any COLLATE specification is ignored.
DBLANG
The value of DBLANG is used to complete the pathname to the directories
that contain the required message, help, and demo files. The format of
DBLANG is the same as that of DB_LOCALE.
See also the description of DBLANG in the Informix Guide to GLS Functionality.
DBDATE
The DBDATE environment variable has been modified to support era-based
dates (Japanese and Taiwanese). The days of the week and months of the year
(in local form) are stored in the locale files. If this environment variable is set,
it might override other means of specifying date formats.
DBMONEY
This environment variable has been modified to accept multibyte currency
symbols. INFORMIX-SQL must read the value of DBMONEY (or DBFORMAT)
and be able to correctly process multibyte characters as currency symbols. If
DBMONEY is set, its value might override other means of specifying currency
formats.
DBFORMAT
This environment variable has been modified to accept multibyte currency
symbols. Unlike the version of DBFORMAT for English products, display of
the decimal point is optional, rather than mandatory, in INFORMIX-SQL.
If DBFORMAT is set, its value can override other means of specifying number
or monetary formats.
The glfiles utility is described in the Informix Guide to GLS Functionality. This
utility allows you to generate lists of the following files:
The following table shows the values assumed by INFORMIX-SQL when you
define only some of the required values of locales.
No -- No -- en_us.8859 en_us.8859
If you do not set the DBLANG environment variable, it is set to the value of
CLIENT_LOCALE.
For more information about the LANG environment variable, see the Informix
Guide to SQL: Reference.
CLIENT_LOCALE DB_LOCALE
The code sets in the CLIENT_LOCALE can differ from those in DB_LOCALE.
For details of converting between client and server code sets, see the sections
that follow. See also the Informix Guide to GLS Functionality.
This appendix uses the term code set in the same way that the Windows
documentation uses the terms character set and code page.
Code-set conversion does not create a character in the target code set if the
character exists only in the source code set. For example, if the character
a-circumflex is being passed to a computer whose code set does not contain an
a-circumflex character, the target computer will never be able to exactly
process or print the a-circumflex character. This situation is described in more
detail in “Mismatch Processing” on page C-24.
Mismatch Processing
If both code sets encode exactly the same characters, then mismatch handling
is unnecessary. If the source code set contains any characters that are not
contained in the target code set, however, the conversion must define how
the mismatched characters are to be mapped to the target code set.
Because each operating system has its own way of declaring the code set
it is using, consult your UNIX operating system documentation or your
system administrator to determine the code set used by the client computer.
Your system administrator should also know which code set is being used
by the database.
Set the DBAPICODE environment variable to specify a code set that has
a mapping file in the message directory $INFORMIXDIR/msg (or a directory
pointed to by the LANG or DBLANG value). The Informix crtcmap utility
helps you to create mapping files.
For detailed information about DBAPICODE and the crtcmap utility, see the
Informix Guide to SQL: Reference. ♦
Because terminfo does not support color, you can only use
INFORMIX-SQL color functionality with termcap. If you want to
use color in INFORMIX-SQL screen forms, you must set
INFORMIXTERM to termcap.
You can use the information in this appendix, combined with the
information in your terminal manual, to modify the contents of
your termcap file or terminfo files. This appendix is divided into
two main sections, termcap and terminfo. Depending on which
you are using, you should read the appropriate section.
termcap
termcap
When INFORMIX-SQL is installed on your system, a termcap file is placed in
the etc subdirectory of $INFORMIXDIR. This file is a superset of an operating-
system termcap file. The Informix termcap file contains additional capabil-
ities for many terminals. You might want to modify this file further in the
following instances:
■ The entry for your terminal has not been modified to include color-
change and intensity-change capabilities.
■ You want to specify or alter the graphics characters used for borders.
Tip: Some terminals cannot support color or graphics characters. You should read
this appendix and the user guide that comes with your terminal to determine whether
or not the changes described in this appendix are applicable to your terminal.
A termcap entry contains a list of names for the terminal, followed by a list
of the terminal’s capabilities. The three types of capabilities are:
■ Boolean
■ Numeric
■ String
Figure D-1 shows a basic termcap entry for the Wyse 50 terminal.
Figure D-1
# Entry for Wyse 50:
Wyse 50 termcap
w5|wy50|wyse50:\ Entry
:if=/usr/lib/tabset/std:\
:al=\EE:am:bs:ce=\Et:cm=\E=%+ %+ :cl=\E*:co#80:\
:dc=\EW:dl=\ER:ho=^^:ei=:kh=^^:im=:ic=\EQ:in:li#24:\
:nd=^L:pt:se=\EG0:so=\EG4:sg#1:ug#1:\
:up=^K:ku=^K:kd=^J:kl=^H:kr=^L:kb=:\
:k0=^A@^M:k1=^AA^M:k2=^AB^M:k3=^AC^M:k4=^AD^M:\
:k5=^AE^M:k6=^AF^M:k7=^AG^M:\
:HI=^|:Po=^R:Pe=^T:
Terminal Names
A termcap entry starts with one or more names for the terminal, each of
which is separated by a vertical bar ( | ). For example, the termcap entry for
the Wyse 50 terminal starts with the following line:
w5|wy50|wyse50:\
The termcap entry can be accessed with any one of these names.
Boolean Capabilities
A Boolean capability is a two-character code that indicates whether or
not a terminal has a specific feature. If the Boolean capability is present in the
termcap entry, the terminal has that particular feature. Figure D-2 shows
some of the Boolean capabilities for the Wyse 50 terminal.
Numeric Capabilities
A numeric capability is a two-character code followed by a pound symbol
( # ) and a value. Figure D-3 shows the numeric capabilities for the number
of columns and the number of lines on a Wyse 50 terminal.
Figure D-3
:co#80:li#24: Numeric
Capabilities
# co number of columns in a line
for the Wyse 50
# li number of lines on the screen
String Capabilities
A string capability specifies a sequence that can be used to perform a terminal
operation. A string capability is a two-character code followed by an equal
sign ( = ) and a string ending at the next delimiter ( : ).
Most termcap entries include string capabilities for clearing the screen,
cursor movement, arrow keys, the underscore, function keys, and so on.
Figure D-4 shows many of the string capabilities for the Wyse 50 terminal.
Figure D-4
:ce=\Et:cl=\E*:\ String Capabilities
:nd=^L:up=^K:\ for the Wyse 50
:so=\EG4:se=\EG0:\
:ku=^K:kd=^J:kr=^L:kl=^H:\
:k0=^A@^M:k1=^AA^M:k2=^AB^M:k3=^AC^M:
Perform the following steps to modify the definition for your terminal type
in the termcap file:
horizontal - z
vertical 6
Tip: You might want to make a copy of your termcap file before you edit it. You can
use the TERMCAP environment variable to point to whichever copy of the termcap
file you want to access.
Use the format
termcap-capability=value
to enter values for the following termcap capabilities:
gs The escape sequence for entering graphics mode. In the term-
cap file, ESCAPE is represented as a backslash ( \ ) followed by
the letter E; CONTROL is represented as a caret ( ^ ). For exam-
ple, the Wyse 50 escape sequence ESCAPE-H CONTROL-B is
represented as \EH^B.
The following example shows possible values for gs, ge, and gb in an entry
for a terminal without graphics capabilities. In this example, window borders
would be drawn using underscores ( _ ) for horizontal lines, vertical bars
( | ) for vertical lines, periods ( . ) for the top corners, and vertical bars ( | )
for the lower corners.
:gs=:ge=:gb=.|.|_|:
INFORMIX-SQL uses the graphics characters in the termcap file when you
specify a screen border in a PERFORM screen.
Figure D-6
Color-Monochrome Correspondence
Color Monochrome
Number Terminal Terminal
0 WHITE NORMAL
1 YELLOW BOLD
2 MAGENTA BOLD
3 RED BOLD†
4 CYAN DIM
5 GREEN DIM
6 BLUE DIM†
7 BLACK INVISIBLE
The background for colors is BLACK in all cases. In Figure D-6, the † signifies
that, if the keyword BOLD is indicated as the attribute, the field will be RED
on a color terminal, or if the keyword DIM is indicated as the attribute, the
field will be BLUE on a color terminal.
In either color or monochrome mode, you can add the REVERSE, BLINK, or
UNDERLINE attributes if your terminal supports them. You can select only
one of these three attributes.
ZA uses the values of these four parameters and a stack machine to determine
which characters to send to the terminal. The ZA function is called and these
parameters are evaluated when a color attribute specification is encountered
during PERFORM. You can use the information in your terminal manual to set
the ZA parameters to the correct values for your terminal.
To define the ZA string for your terminal, you use stack operators to push and
pop values onto and off the stack. The next section describes several stack
operators. Use these descriptions and the subsequent examples to under-
stand how to define the string for your terminal.
Stack Operations
The ZA string uses stack operations to either push values onto the stack or
pop values off the stack. Typically, the instructions in the ZA string push a
parameter onto the stack, compare it to one or more constants, and then send
an appropriate sequence of characters to the terminal. More complex opera-
tions are often necessary and, by storing the display attributes in static stack
machine registers (named a through z), you can achieve terminal-specific
optimizations.
A summary follows of the different stack operators you can use to write the
descriptions. For a complete discussion of stack operators, consult your
operating system documentation.
%2d pops a numeric value from the stack and sends a maximum of two
digits to the terminal, padding to two places. For example, if the
value 145 is at the top of the stack, %2d pops the value off the stack
and sends the ASCII representations of 4 and 5 to the terminal. If
the value 5 is at the top of the stack, %2d pops the value off the
stack and sends the ASCII representations of 0 and 5 to the termi-
nal.
%3d pops a numeric value from the stack and sends a maximum of
three digits to the terminal, padding to three places. For example,
if the value 7 is at the top of the stack, %3d pops the value off the
stack and sends the ASCII representations of 0, 0, and 7 to the ter-
minal.
%c pops a single character from the stack and sends it to the terminal.
%P[a-z] pops a value from the stack and stores it in the specified variable.
The notation for variables is Pa, Pb, ... Pz. For example, if the value
45 is on the top of the stack, %Pb pops 45 from the stack and stores
it in the variable Pb.
%g[a-z] gets the value stored in the corresponding variable (P[a-z]) and
pushes it on the stack. For example, if the value 45 is stored in the
variable Pb, %gb gets 45 from Pb and pushes it on the stack.
%´c´ pushes a single character on the stack. For example, %’k’ pushes k
on the stack.
%{n} pushes an integer constant on the stack. The integer can be any
length and can be either positive or negative. For example, %{0}
pushes the value 0 on the stack.
%S[a-z] pops a value from the stack and stores it in the specified static vari-
able. (Static storage is nonvolatile since the stored value remains
from one attribute evaluation to the next.) The notation for static
variables is Sa, Sb, ... Sz. For example, if the value 45 is on the top
of the stack, %Sb pops 45 from the stack and stores it in the static
variable Sb. This value is accessible for the duration of the
INFORMIX-SQL program.
%G[a-z] gets the value stored in the corresponding static variable (S[a-z])
and pushes it on the stack. For example, if the value 45 is stored in
the variable Sb, %Gb gets 45 from Sb and pushes it on the stack.
Arithmetic Operators
Each arithmetic operator pops the top two values from the stack, performs an
operation, and pushes the result on the stack.
Bit Operators
The following bit operators pop the top two values from the stack, perform
an operation, and push the result on the stack:
%& Bit-and. For example, %{12}%{21}%& is equivalent to (12 and 21) and
produces a result of 4.
Binary Decimal
0 1 1 0 0 = 12
1 0 1 0 1 = 21
---------------------- and
0 0 1 0 0 = 4
0 1 1 0 0 = 12
1 0 1 0 1 = 21
---------------------- or
1 1 1 0 1 = 29
0 1 1 0 0 = 12
1 0 1 0 1 = 21
---------------------- exclusive or
1 1 0 0 1 = 25
The following unary operator pops the top value from the stack, performs an
operation, and pushes the result on the stack:
0 0 0 1 1 0 0 1 = 25
------------------------------------- Complement
1 1 1 0 0 1 1 0 = -26
Logical Operators
The following logical operators pop the top two values from the stack,
perform an operation, and push the logical result (either 0 for false or 1 for
true) on the stack:
%= Equal to. For example, if the parameter p1 has the value 3, the expres-
sion %p1%{2}%= is equivalent to 3=2 and produces a result of 0 (false).
%> Greater than. For example, if the parameter p1 has the value 3, the
expression %p1%{0}%> is equivalent to 3>0 and produces a result of 1
(true).
%< Less than. For example, if the parameter p1 has the value 3, the expres-
sion %p1%{4}%< is equivalent to 3<4 and produces a result of 1 (true).
The following unary operator pops the top value from the stack, performs an
operation, and pushes the logical result (either 0 or 1) on the stack.
%! Logical negation. This operator produces a value of zero for all non-
zero numbers and a value of 1 for zero. For example, %{2}%! results in
a value of 0, and %{0}%! results in a value of 1.
Conditional Statements
The condition statement IF-THEN-ELSE has the following format:
The %e elsepart is optional. You can nest conditional statements in the thenpart
or the elsepart.
is equivalent to:
if p1 = 3 then print ";31"
Summary of Operators
Figure D-7 summarizes the allowed operations.
Figure D-7
Stack Operations
Operation Description
Operation Description
All other characters are written to the terminal; use ’%%’ to write ’%’.
(2 of 2)
Examples
To illustrate, consider the monochrome Wyse terminal. Figure D-8 shows the
sequences for various display characteristics.
Figure D-8
ESCAPE G 0 Normal Wyse Escape
ESCAPE G 1 Blank(invisible) Sequences
ESCAPE G 2 Blink
ESCAPE G 4 Reverse
ESCAPE G 5 Reverse and blank
ESCAPE G 6 Reverse and blink
ESCAPE G 8 Underscore
ESCAPE G 9 Underscore and blank
ESCAPE G : Underscore and blink
The characters after G form an ASCII sequence from the character 0 (zero)
through ?. You can generate the character by starting with 0 and adding 1 for
blank, 2 for blink, 4 for reverse, and 8 for underline.
You can construct the termcap entry in stages, as outlined in the following
display. %pi refers to pushing the ith parameter on the stack. The designation
for is \E. The termcap entry for the Wyse terminal must contain the following
ZA entry in order for INFORMIX-SQL monochrome attributes such as
REVERSE and BOLD to work correctly:
ZA =
\EG #print \EG
%’0’#push ’0’ (normal) on the stack
%?%p1%{7}%=%t%{1}%|#if p1 = 7 (invisible), set
#the 1 bit (blank);
%e%p1%{3}%> #if p1 > 3 and < 7, set the 64 flag (dim);
%p1%{7}%<%&%t%{64}%|#
%;%;#
%?%p2%t%{4}%|%;#if p2 is set, set the 4 bit (reverse)
%?%p3%t%{2}%|%;#if p3 is set, set the 2 bit (blink)
%?%p4%t%{8}%|%;#if p4 is set, set the 8 bit (underline)
%c: #print whatever character
# is on top of the stack
You then concatenate these lines as a single string that ends with a colon and
has no embedded NEWLINEs. The actual ZA entry for the Wyse 50 terminal
follows:
ZA = \EG%’0’%?%p1%{7}%=%t%{1}%|%e%p1%{3}%>%p1%{7}%<%&%t%{64}
%|%;%;%?%p2%t%{4}%|%;%?%p3%t%{2}%|%;%?%p4%t%{8}%|%;%c:
The next example is for the ID Systems Corporation ID231, a color terminal.
On this terminal, to set color and other characteristics you must enclose a
character sequence between a lead-in sequence (ESCAPE [ 0) and a termi-
nating character (m). The first in the sequence is a two-digit number that
determines whether the assigned color is in the background (30) or in the
foreground (40). The next is another two-digit number that is the other of 30
or 40, incremented by the color number. These characters are followed by 5 if
there is blinking and by 4 for underlining. The code in Figure D-9 sets up the
entire escape sequence.
Figure D-9
ZA = Sample ZA String
\E[0;#print lead-in
%?%p1%{0}%=%t%{7}#encode color number (translate
for ID231
%e%p1%{1}%=%t%{3}# from Figure D-6 to the number
%e%p1%{2}%=%t%{5}# for the ID231)
%e%p1%{3}%=%t%{1}#
%e%p1%{4}%=%t%{6}#
%e%p1%{5}%=%t%{2}#
%e%p1%{6}%=%t%{4}#
%e%p1%{7}%=%t%{0}%;#
%?%p2%t30;%{40}%+%2d#if p2 is set, print ’30’ and
# ’40’ + color number (reverse)
%e40;%{30}%+%2d%;# else print ’40’ and
# ’30’ + color number (normal)
%?%p3%t;5%;#if p3 is set, print 5 (blink)
%?%p4%t;4%;#if p4 is set, print 4 (underline)
m #print ’m’ to end character
# sequence
terminfo
If you have set the INFORMIXTERM environment variable to terminfo,
INFORMIX-SQL uses the terminfo directory indicated by the TERMINFO
environment variable (or /usr/lib/terminfo if TERMINFO is not set).
INFORMIX-SQL uses the information in terminfo to draw borders and display
certain intensity attributes.
You might want to modify a file in the terminfo directory if you want to
specify or change the graphics characters used for borders in screen forms.
Tip: If you use terminfo (instead of termcap), you cannot use color or certain
intensity attributes with INFORMIX-SQL. To use color attributes with
INFORMIX-SQL, you must use termcap.
Some terminals cannot support graphics characters. You should read this
appendix and the user guide that comes with your terminal to determine
whether or not the changes described in this appendix are applicable to your
terminal.
A terminfo entry contains a list of names for the terminal, followed by a list
of the terminal’s capabilities. The three types of capabilities are:
■ Boolean
■ Numeric
■ String
Figure D-11 shows a basic terminfo entry for the Wyse 50 terminal.
Figure D-11
. Entry for Wyse 50: Wyse 50
w5|wy50|wyse50,
terminfo Entry
am, cols#80, lines#24, cuul=^K, clear=^Z,
home=^^, cuf1=^L, cup=\E=%p1%’\s’%+%c%p2%’\s’%+%c,
bw, ul, bel=^G, cr=\r, cud1=\n, cub1=\b, kpb=\b, kcud1=\n,
kdub1=\b, nel=\r\n, ind=\n,
xmc#1, cbt=\EI,
Terminal Names
A terminfo entry starts with one or more names for the terminal (each
separated by a vertical bar ( | )). For example, the terminfo entry for the
Wyse 50 terminal starts with the following line:
w5|wy50|wyse50,
The terminfo entry can be accessed using any one of these names.
Boolean Capabilities
A Boolean capability is a two- to five-character code that indicates whether
or not a terminal has a specific feature. If the Boolean capability is present in
the terminfo entry, the terminal has that particular feature.
Figure D-12 shows some of the Boolean capabilities for the Wyse 50 terminal.
Figure D-12
bw,am, Boolean
. bwbackward wrap
Capabilities
. amautomatic margins for the Wyse 50
Numeric Capabilities
A numeric capability is a two- to five-character code followed by a pound
symbol ( # ) and a value. Figure D-13 shows the numeric capabilities for the
number of columns and the number of lines on a Wyse 50 terminal.
Figure D-13
cols#80,lines#24, Numeric
. colsnumber of columns in a line
Capabilities
. linesnumber of lines on the screen for the Wyse 50
String Capabilities
A string capability specifies a sequence that can be used to perform a terminal
operation. A string capability is a two- to five-character code followed by an
equal sign ( = ) and a string ending at the next delimiter ( , ).
Most terminfo entries include string capabilities for clearing the screen,
cursor movement, arrow keys, underscore, function keys, and so on.
Figure D-14 shows many of the string capabilities for the Wyse 50 terminal.
Figure D-14
el=\ET,clear=\E*, String
cuf1=^L,cuu1=^K, Capabilities
smso=\EG4,rmso=\EG0,
kcuu1=^K,kcud1=^J,kcuf1=^L,kcub1=^H, for the
kf0=^A@^M,kf1=^AA^M,kf2=^AB^M,kf3=^AC^M, Wyse 50
. smso=\EG4start stand-out
. rmso=\EG0end stand-out
. kf0=^A@^Mfunction key F1
. kf1=^AA^Mfunction key F2
. kf2=^AB^Mfunction key F3
. kf3=^AC^Mfunction key F4
Look at the terminfo source file (using infocmp) to see if the entry for your
terminal includes these definitions (look for the acsc capability, described
later in this section). If the file does not contain border character definitions
for your terminal type, or if you want to specify alternative border characters,
you or your system administrator can modify the terminfo source file. Refer
to your operating-system documentation for a description of how to
decompile terminfo entries using the infocmp program.
To specify border characters in the terminfo source file for your terminal
horizontal - z
vertical 6
Tip: You might want to make a copy of your terminfo directory before you edit files.
You can use the TERMINFO environment variable to point to whichever copy of the
terminfo directory you want to access.
Use the format:
terminfo-capability=value
to enter values for the following terminfo capabilities:
smacs The escape sequence for entering graphics mode. In a
terminfo file, ESCAPE is represented as a backslash ( \ )
followed by the letter E; CONTROL is represented as a caret
( ^ ). For example, the Wyse 50 escape sequence ESCAPE-H
CONTROL-B is represented as \EH^B.
acsc The concatenated, paired list of ASCII equivalents for the six
graphics characters used to draw the border. You can
specify the characters in any order, but you must pair the
ASCII equivalents for your terminal with the following
system default characters.
Figure D-16
System Default Characters for Border Positions
horizontal q
vertical x
4. Use tic to recompile the modified terminfo file. See your operating-
system documentation for a description of the tic program.
The following example shows the full setting for specifying alternative
border characters on the Wyse 50:
smacs=\EH^B, . sets smacs to ESC H CTRL B
rmacs=\EH^C, . sets rmacs to ESC H CTRL C
acsc=l2m1k3j5qzx6, . sets acsc to the ASCII equivalents
. of graphics characters for upper
. left (l), lower left (m), upper right (k),
. lower right (j), horizontal (q),
. and vertical (x)
The following example shows possible values for smacs, rmacs, and acsc in
an entry for a terminal without graphics capabilities. In this example,
window borders would be drawn using underscores ( _ ) for horizontal lines,
vertical bars ( | ) for vertical lines, periods ( . ) for the top corners, and vertical
bars ( | ) for the lower corners.
smacs=,rmacs=,acsc=l.m|k.j|q_x|,
INFORMIX-SQL uses the graphics characters in the terminfo file when you
specify a screen border in a PERFORM screen.
If the terminfo entry for your terminal contains the ul and so attributes, you
can use the UNDERLINE and REVERSE intensity attributes, however. You can
see if your terminfo entry includes these capabilities by using the infocmp
program. Refer to your operating-system documentation for information
about infocmp.
If you want to use color and intensity in your INFORMIX-SQL screen forms,
you must use termcap (by setting the INFORMIXTERM environment variable
to termcap, and by setting the TERMCAP environment variable to
$INFORMIXDIR/etc/termcap). For more information, refer to the
“Environment Variables” Appendix and the Preface.
0 ^@ 43 + 86 V
1 ^A 44 , 87 W
2 ^B 45 - 88 X
3 ^C 46 . 89 Y
4 ^D 47 / 90 Z
5 ^E 48 0 91 [
6 ^F 49 1 92 \
7 ^G 50 2 93 ]
8 ^H 51 3 94 ^
9 ^I 52 4 95 _
10 ^J 53 5 96 ‘
11 ^K 54 6 97 a
12 ^L 55 7 98 b
13 ^M 56 8 99 c
14 ^N 57 9 100 d
15 ^O 58 : 101 e
16 ^P 59 ; 102 f
17 ^Q 60 < 103 g
18 ^R 61 = 104 h
19 ^S 62 > 105 i
20 ^T 63 ? 106 j
21 ^U 64 @ 107 k
22 ^V 65 A 108 l
(1 of 2)
23 ^W 66 B 109 m
24 ^X 67 C 110 n
25 ^Y 68 D 111 o
26 ^Z 69 E 112 p
27 esc 70 F 113 q
28 ^\ 71 G 114 r
29 ^] 72 H 115 s
30 ^^ 73 I 116 t
31 ^_ 74 J 117 u
32 75 K 118 v
33 ! 76 L 119 w
34 " 77 M 120 x
35 # 78 N 121 y
36 $ 79 O 122 z
37 % 80 P 123 {
38 & 81 Q 124 |
39 ’ 82 R 125 }
40 ( 83 S 126 ~
41 ) 84 T 127 del
42 * 85 U
(2 of 2)
Reserved Words
F
In this release of INFORMIX-SQL, very few words are reserved.
You can use the words that were reserved in previous releases of
INFORMIX-SQL as identifiers. For example, you can execute a
statement such as the following:
CREATE TABLE table (column INTEGER,
date DATE, char CHAR(20))
You can avoid this ambiguity by including a table name with the column
name, as shown in the following example:
SELECT [Link] FROM mytab
This ambiguity applies to the aggregate functions (AVG, COUNT, MAX, MIN,
SUM), the LENGTH function, the date functions (DATE, DAY, MDY, MONTH,
WEEKDAY, YEAR), and the datetime function EXTEND. For general descrip-
tions of these functions, refer to the Informix Guide to SQL: Tutorial.
If you use the keyword TODAY, CURRENT, or USER as a column name,
ambiguity can also occur, as shown in the following example:
CREATE TABLE mytab (user CHAR(10),
current DATETIME HOUR TO SECOND,today DATE)
The database server interprets user, current, and today in the SELECT
statement as the functions USER, CURRENT, and TODAY. Thus, instead of
returning josh, 11:30:30,1/22/89, the SELECT statement returns the
current user name, the current time, and the current date.
If you want to select the actual columns of the table, you must write the
SELECT statement in one of two ways:
or, equivalently:
SELECT * FROM mytab
For general descriptions of the TODAY, CURRENT, and USER functions, see
the Informix Guide to SQL: Tutorial.
To include a column name all in a SELECT statement, you can include the ALL
keyword prior to the all column name, as shown in the following example:
SELECT ALL all FROM mytab
You can also prefix the column name with the table name. For example, you
could specify the following:
SELECT [Link] FROM mytab
You can, however, name a column unique by using two statements. The first
statement creates the column mycol; the second statement renames the
column mycol to unique, as follows:
CREATE TABLE mytab (mycol INTEGER)
You can also include the owner name as well as the table name:
SELECT [Link] FROM [Link]
For example, using statistics as a table name causes the following UPDATE
statement to fail because the database server interprets it as part of the
UPDATE STATISTICS syntax rather than as a table name in an UPDATE
statement:
UPDATE statistics SET mycol = 10
Using outer as a table name causes the following SELECT statement to fail
because the database server interprets outer as a keyword for performing an
outer join:
SELECT mycol FROM outer
Again, by specifying an owner name with the table name, you can avoid any
ambiguity and create a SELECT statement that executes properly, as shown in
the following example:
SELECT mycol FROM [Link]
Because the AS keyword syntax is a part of the proposed ANSI SQL2 standard,
but is not included in the ANSI SQL89 standard, the database server generates
ANSI warnings if you use the AS keyword and one of the following state-
ments is true:
■ MINUTE
■ SECOND
■ FRACTION
For example, the following statement fails because the database server inter-
prets units as a DATETIME qualifier for the column named mycol:
SELECT mycol units FROM mytab
By using the keyword AS, however, you can avoid any ambiguity, as shown
in the following example:
SELECT mycol AS units FROM mytab
You must also use the AS keyword to select a column labeled as or from. For
example, the following statement fails because INFORMIX-SQL does not find
the required FROM clause. INFORMIX-SQL interprets the column label as as the
keyword AS. INFORMIX-SQL then interprets the keyword FROM as the column
label to assign to mycol:
SELECT mycol as FROM mytab
By using the keyword AS, however, you can avoid any ambiguity, as shown
in the following example:
SELECT mycol AS as FROM mytab
The following statement fails because the database server expects a table
name to follow the first from:
SELECT mycol from FROM mytab
By using the keyword AS, however, you can identify the first from as a
column label, as shown in the following example:
SELECT mycol AS from FROM mytab
For example, the following statement fails because the database server inter-
prets order as part of an ORDER BY clause:
SELECT * FROM mytab order
By using the keyword AS, however, you can identify order as a table alias:
SELECT * FROM mytab AS order
You must also use the keyword AS to give a table the alias of WITH, CREATE,
or GRANT. For example, the following statement fails because the database
server interprets with as part of the WITH CHECK OPTION syntax:
SELECT * FROM mytab with
By using the keyword AS, however, you can identify with as a table alias, as
shown in the following example:
SELECT * FROM mytab AS with
The following statement fails because the database server interprets the
keyword create as part of the syntax to create an entity such as a table,
synonym, or view:
SELECT * FROM mytab create
By using the keyword AS, however, you can identify create as a table alias, as
shown in the following example:
SELECT * FROM mytab AS create
Figure G-1
INFORMIX-SQL Main menu Options
Form Run, Modify, Generate, New, Compile, Drop
Report Run, Modify, Generate, New, Compile, Drop
isql -f
INFORMIX-SQL returns you to the operating system after you complete the
specified operation.
isql -r
INFORMIX-SQL returns you to the operating system after you complete the
specified operation.
isql -q
INFORMIX-SQL returns you to the operating system after you complete the
specified operation.
The following command chooses the ex1 file and makes the SQL statements
it contains the current statements:
isql -s stores7 -qc ex1
isql -d
INFORMIX-SQL returns you to the operating system after you complete the
specified operation.
The following statement calls the Select option on the DATABASE menu:
isql -s -ds
-u
INFORMIX-SQL returns you to the operating system after you complete the
specified operation.
The following command runs the User-menu for the stores7 demonstration
database:
isql stores7 -ur
isql -t
INFORMIX-SQL returns you to the operating system after you complete the
specified operation.
FORMBUILD
The command syntax for compiling a customized screen form directly from
the operating system is as follows.
sformbld -d
filename
-s -l lines -c cols -v
filename is the name of the form specification file. Do not include the .per
extension ([Link]) on the command line.
-d replaces filename and instructs FORMBUILD to prompt you for the
information required to create and compile a default form
specification.
Usage
If the compilation is successful, FORMBUILD creates a compiled form
specification named [Link]. You can use this compiled form specifi-
cation with PERFORM as a screen form. If the compilation is unsuccessful,
FORMBUILD creates an error file named [Link]. You must edit the error
file, remove the error messages, and recompile with FORMBUILD before you
can use the screen form.
You can also create a customized screen form directly from the operating
system using the shortened version of the INFORMIX-SQL Main menu
options. This method is described earlier in this appendix.
PERFORM
The command syntax for running a compiled screen form directly from the
operating system is as follows.
sperform filename
Usage
The maximum number of filenames you can include on the command line is
operating-system dependent.
PERFORM displays each form in the order that it appears on the command
line.
You can also run a compiled screen form directly from the operating system
using the shortened version of the INFORMIX-SQL Main menu options. This
method is described earlier in this appendix.
ACEPREP
The command syntax for compiling a customized report form directly from
the operating system is as follows.
saceprep filename
-s -ansi -o directory-name
Usage
If the compilation is successful, ACEPREP creates a compiled report specifi-
cation file named [Link]. You can use this compiled report specification
with ACEGO to produce a report. If the compilation is unsuccessful, ACEPREP
creates an error file named [Link]. You must edit the error file, remove
the error messages, and recompile with ACEPREP before you can run the
report.
You can also compile a customized report form directly from the operating
system using the shortened version of the INFORMIX-SQL Main menu
options. This method is described in “Accessing REPORT Menu Options” on
page G-3.
ACEGO
The command syntax for running a compiled report directly from the
operating system is as follows.
sacego filename
-s -d database-name
Usage
The maximum number of filenames you can include on the command line is
operating-system dependent.
ACEGO executes each report in the order in which it appears on the command
line.
You can also run a compiled report directly from the operating system using
the shortened version of the INFORMIX-SQL Main menu options. This method
is described in “Accessing REPORT Menu Options” on page G-3.
Notices
H
IBM may not offer the products, services, or features discussed
in this document in all countries. Consult your local IBM repre-
sentative for information on the products and services currently
available in your area. Any reference to an IBM product,
program, or service is not intended to state or imply that only
that IBM product, program, or service may be used. Any
functionally equivalent product, program, or service that does
not infringe any IBM intellectual property right may be used
instead. However, it is the user’s responsibility to evaluate and
verify the operation of any non-IBM product, program, or
service.
IBM may have patents or pending patent applications covering
subject matter described in this document. The furnishing of this
document does not give you any license to these patents. You
can send license inquiries, in writing, to:
Any references in this information to non-IBM Web sites are provided for
convenience only and do not in any manner serve as an endorsement of those
Web sites. The materials at those Web sites are not part of the materials for
this IBM product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it
believes appropriate without incurring any obligation to you.
Licensees of this program who wish to have information about it for the
purpose of enabling: (i) the exchange of information between independently
created programs and other programs (including this one) and (ii) the mutual
use of the information which has been exchanged, should contact:
IBM Corporation
J74/G4
555 Bailey Ave
P.O. Box 49023
San Jose, CA 95161-9023
U.S.A.
The licensed program described in this information and all licensed material
available for it are provided by IBM under terms of the IBM Customer
Agreement, IBM International Program License Agreement, or any equiv-
alent agreement between us.
All IBM prices shown are IBM’s suggested retail prices, are current and are
subject to change without notice. Dealer prices may vary.
Notices H-3
Trademarks
Each copy or any portion of these sample programs or any derivative work,
must include a copyright notice as follows:
If you are viewing this information softcopy, the photographs and color illus-
trations may not appear.
Trademarks
AIX; DB2; DB2 Universal Database; Distributed Relational Database
Architecture; NUMA-Q; OS/2, OS/390, and OS/400; IBM Informix;
C-ISAM; Foundation.2000TM; IBM Informix 4GL; IBM Informix
DataBlade Module; Client SDKTM; CloudscapeTM; CloudsyncTM;
IBM Informix Connect; IBM Informix Driver for JDBC; Dynamic
ConnectTM; IBM Informix Dynamic Scalable ArchitectureTM (DSA);
IBM Informix Dynamic ServerTM; IBM Informix Enterprise Gateway
Manager (Enterprise Gateway Manager); IBM Informix Extended Parallel
ServerTM; [Link] ServicesTM; J/FoundationTM; MaxConnectTM; Object
TranslatorTM; Red Brick Decision ServerTM; IBM Informix SE;
IBM Informix SQL; InformiXMLTM; RedBack; SystemBuilderTM; U2TM;
UniData; UniVerse; wintegrate are trademarks or registered trademarks
of International Business Machines Corporation.
Java and all Java-based trademarks and logos are trademarks or registered
trademarks of Sun Microsystems, Inc. in the United States and other
countries.
Windows, Windows NT, and Excel are either registered trademarks or trade-
marks of Microsoft Corporation in the United States and/or other countries.
Other company, product, and service names used in this publication may be
trademarks or service marks of others.
Index
Index
Index 3
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
Index 5
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
Index 7
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
Index 9
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
Index 11
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
W
WEEKDAY( ) function, in ACE
reports 4-107
Western European languages C-15
WHILE statement, in ACE
reports 4-78
White-space characters C-2, C-8,
C-12
Wildcard characters, in
PERFORM 3-36
WITHOUT NULL INPUT
option 2-40
WORDWRAP
and blobs 2-65
and VARCHAR data 2-64
expression, in ACE reports 4-108
keyword 2-65