Академический Документы
Профессиональный Документы
Культура Документы
User Guide
Published by INFORMIX Press Informix Software, Inc. 4100 Bohannon Drive Menlo Park, CA 94025 The following are worldwide trademarks of Informix Software, Inc., or its subsidiaries, registered in the United States of America as indicated by an , and in numerous other countries worldwide:
INFORMIX and C-ISAM.
The following are worldwide trademarks of the indicated owners or their subsidiaries, registered in the United States of America as indicated by an , and in numerous other countries worldwide: X/OpenCompany Ltd.: UNIX; X/Open Adobe Systems Incorporated: Post Script Some of the products or services mentioned in this document are provided by companies other than Informix. These products or services are identied by the trademark or servicemark of the appropriate company. If you have a question about one of those products or services, please call the company in question directly. ACKNOWLEDGMENTS The following people contributed to this version of INFORMIX-SQL User Guide: Documentation Team: Technical Contributors: Adam Barnett, Diana Boyd, Lisa Braz, Mitch Gordon, Liz Knittel, Todd Katz Radovan Binar, Jon Dietch, Chris Horak, Jonathan Lefer, Jonathan Rende, Kevin Rowney, Elham Sohrab, Patrick Stephens
Copyright 1981-1994 by Informix Software, Inc. All rights reserved. No part of this work covered by the copyright hereon may be reproduced or used in any form or by any meansgraphic, electronic, or mechanical, including photocopying, recording, taping, or information storage and retrieval systemswithout permission of the publisher. RESTRICTED RIGHTS LEGEND Software and accompanying materials acquired with United States Federal Government funds or intended for use within or for any United States federal agency are provided with Restricted Rights as dened in DFARS 252.227-7013(c)(1)(ii) or FAR 52.227-19.
ii
Preface
The INFORMIX-SQL User Guide and its companion volume, the INFORMIXSQL Reference Manual, comprise the comprehensive documentation for the INFORMIX-SQL (I-SQL) relational database management system. The INFORMIX-SQL User Guide is an introduction to I-SQL. You do not need database management experience or familiarity with basic database management concepts to use this manual. The INFORMIX-SQL User Guide 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. The rst chapter covers important basic information about database systems. Subsequent chapters contain instructions and illustrations that show you how to take advantage of many of the powerful I-SQL features. Each chapter also tells you where to look in the INFORMIX-SQL Reference Manual for information about advanced features. The INFORMIX-SQL Reference Manual is a complete reference to the programs that make up I-SQL. It contains information about everything you can do with I-SQL, and it is organized by program name. Once you are familiar with I-SQL basics, you can use the INFORMIX-SQL Reference Manual to learn about advanced features and to quickly locate specic information.
Summary of Chapters
Each chapter in this book begins with a section describing chapter contents. This section includes a paragraph to help you identify topics appropriate for your needs. The rest of the chapter explains each topic area and demonstrates its use in I-SQL.
The INFORMIX-SQL User Guide includes the following chapters and appendixes:
Chapter 6, Creating Your Own Forms, describes how you can create
your own custom screen forms.
Chapter 7, Using SQL, describes the SQL query language, which you
can use to enter, alter, delete, or retrieve data from the database.
Chapter 8, Creating and Printing Reports, explains how to create, display, and print reports.
iv
Preface
Related Reading
Related Reading
If you have had no prior experience with database management, you should refer to the Informix Guide to SQL: Tutorial, Version 4.1. If you want additional technical information on database management, consider consulting the following texts by C. J. Date:
A Practical Guide to the UNIX System by M. Sobell (Benjamin/Cummings Publishing, 1984) Publishing, 1985)
Preface
Related Reading
vi
Preface
Table of Contents
Table of Contents
Introduction
Documentation Included with INFORMIX-SQL 4 Other Useful Documentation 4 Conventions of this Manual 5 Typographical Conventions 5 Syntax Conventions 5 Useful On-Line Files 6 On-Line Error Messages 7 The STORES Demonstration Application and Database 8 New Features in INFORMIX-SQL 8 NLS Support 8 Improved Performance 8 Improved Quality 9 Compliance with Industry Standards 9 Preparing to Use INFORMIX-SQL 9 Setting Environment Variables 9 Using Your Terminal 12 Restricting Database Access 13 Informix Database Engines 13
Chapter 1
Introducing INFORMIX-SQL
Chapter Overview 1-3 What Is INFORMIX-SQL? 1-3 What Is a Database? 1-4 How INFORMIX-SQL Stores Data 1-4 Retrieving Data from the Database 1-7 Connecting Tables Through Column Joins Getting Started with INFORMIX-SQL 1-11 The INFORMIX-SQL Main Menu 1-12 The Current Option 1-12 The Message Line 1-12
1-9
Moving the Highlight 1-13 Selecting an Option 1-13 What the Main Menu Options Mean 1-13 Using the HELP Menu 1-16 The INFORMIX-SQL Facilities 1-16 Creating Tables with the Schema Editor 1-17 Using a Screen Form 1-18 The Report Writing Facility 1-20 Using a Structured Query Language 1-23 The User-Menu System 1-25 A Complete Database Management System 1-25
Chapter 2
Creating a Database
Chapter Overview 2-3 Two Ways to Create Databases and Tables 2-3 Using the Main Menu to Create Databases and Tables Using SQL to Create Databases and Tables 2-4 Accessing INFORMIX-SQL 2-4 Using the Main Menu to Create a Database 2-5 Guidelines for Selecting Database Names 2-7 The Current Database 2-7 System Files That Make Up a Database 2-8 Selecting a Different Current Database 2-8 Leaving a Current Menu or Screen 2-9 Using the Main Menu to Create a Table 2-9 Naming the New Table 2-11 Using the CREATE TABLE Menu 2-11 An Overview of Building a Table 2-12 Naming the Columns 2-13 Assigning Data Types 2-14 Assigning a Data Type to the Column 2-18 Creating Indexes 2-19 NULL Values 2-21 Adding the Remaining Columns to the Table 2-21 Exiting the Schema Editor 2-22 System Files 2-23 Changing the Table Specications 2-24
2-4
Chapter 3
Entering Data
Chapter Overview 3-3 What Is a Screen Form? 3-3 Screen Forms in the Demonstration Database
3-4
viii
Table of Contents
What Is PERFORM? 3-5 Including Data from Multiple Tables 3-5 Each Table Can Contribute to Several Forms Using a Screen Form 3-6 Choosing the Form You Want 3-7 The PERFORM Screen 3-8 Information Lines 3-8 Screen Form 3-9 Status Lines 3-10 The PERFORM Menu Options 3-10 Adding Data to a Database 3-12 Entering Data in the Fields 3-13 Conrming Your Entry 3-15 Data Checking in PERFORM 3-15 Special Functions 3-16 Positioning the Cursor 3-16 Field Editing 3-17 Using the Multiline Editor 3-18 Storing the Row 3-18 Changing Existing Data 3-18 Removing a Row 3-19 Exiting PERFORM 3-19
3-6
Chapter 4
Querying a Database
Chapter Overview 4-3 What Is a Database Query? 4-3 Searching for an Exact Match 4-4 Searching for a Group of Rows 4-7 Finding All the Rows in a Table 4-9 How Database Queries Work 4-10 Searching with Relational Operators 4-11 Using Wildcard Characters 4-12 Searching for a Range of Values 4-13 Searching for the Highest and Lowest Values 4-14 Searching for Alternative Values 4-15 Query Operators and Short Fields 4-15 Searching in SMALLFLOAT and FLOAT Fields 4-16 Sample Database Queries 4-16 Moving from Screen to Screen 4-17 Saving the Results of a Query 4-17
Table of Contents ix
Chapter 5
Chapter 6
Table of Contents
Verifying Input 6-27 Joining Fields 6-28 The INSTRUCTIONS Section 6-32 Calling C Functions from PERFORM 6-32
Chapter 7
Using SQL
Chapter Overview 7-3 Examples Used in This Chapter 7-3 What is SQL? 7-4 Using SQL Statements 7-4 Accessing SQL 7-5 SQL Options 7-5 The SQL SYNTAX Menu 7-6 Learning How to Use SQL 7-6 Differences between SQL and PERFORM 7-7 How to Create a Table with SQL 7-8 Entering an SQL Statement 7-9 Using the SQL Editor 7-9 Using the Use-Editor Option 7-10 Running an SQL Statement 7-12 If There are Errors 7-12 Saving the Current Statements 7-13 Using a Command File 7-14 Formatting SQL Statements 7-15 Sending Query Results to a Printer or a File 7-16 Displaying Table Information 7-17
Chapter 8
What a Report Specication Contains 8-20 Listing the Instructions 8-20 Including Comments 8-21 Selecting the Data for a Report 8-22 Formatting the Report 8-22 Selecting All Rows and Columns in a Table 8-23 Selecting Data from More than One Table 8-23 Reading the Data for a Report 8-24 Basic Report Formatting 8-25 The OUTPUT Section 8-25 The FORMAT Section 8-26 Creating Page Headers and Trailers 8-27 Printing Rows of Data 8-30 Grouping Data 8-33 Using Calculations in a Report 8-36 Arithmetic Operators 8-36 Controlling the Appearance of Numbers 8-37 Math Functions 8-40 Group Functions 8-45 Displaying a Report 8-47 Printing the Report on a Printer 8-48 Piping the Report to Another Program 8-49 Calling C Functions from ACE 8-49
Chapter 9
9-9
Index
xii
Table of Contents
Introduction
Introduction
Documentation Included with INFORMIX-SQL Other Useful Documentation 4 5 4
Conventions of this Manual 5 Typographical Conventions Syntax Conventions 5 Useful On-Line Files 6 On-Line Error Messages 7
The STORES Demonstration Application and Database New Features in INFORMIX-SQL NLS Support 8 Improved Performance 8 Improved Quality 9 8
Compliance with Industry Standards Preparing to Use INFORMIX-SQL 9 Setting Environment Variables 9 Using Your Terminal 12 13 13
Introduction
INFORMIX-SQL (I-SQL) is a computer-based record-keeping system. As a database management system, I-SQL consists of useful programs or modules that perform data management tasks. I-SQL can substantially reduce the
amount of time required to organize, store, and retrieve information. It can summarize, group, and format information in a variety of helpful ways. With I-SQL, you can perform these database management tasks:
Create, modify, and drop databases and tables Load data from operating system les Run queries using an interactive query language Insert, delete, update, and query on data in the database Create and drop privileges and indexes Create and compile custom forms or reports Create and run custom menus
Introduction
Informix Guide to SQL: Syntax, Version 6.0 Informix Error Messages, Version 6.0
Typographical Conventions
Informix product manuals use a standard set of conventions to introduce new terms, illustrate screen displays, describe command syntax, and so forth. The following typographical conventions are used throughout this manual:
KEYWORD
All keywords appear in UPPERCASE letters. (You can in fact enter keywords in either uppercase or lowercase letters.) New terms and emphasized words are printed in italics. Italics also mark syntax terms for which you must specify some valid identier, expression, keyword, or statement. Database names, table names, column names, utilities, lenames, pathnames, command-line specications, and other similar terms are printed in boldface. Information that I-SQL displays and information that you enter are printed in this typeface.
italics
boldface
monospace
Additionally, when you are instructed to enter or execute text, immediately press RETURN after the entry. When you are instructed to type the text, no RETURN is required. Note that the word RETURN is used throughout this document set rather than ENTER, although your keyboard may perform this function with a key labeled ENTER.
Syntax Conventions
SQL statement syntax is described in the Informix Guide to SQL: Syntax,
Version 6.0. The syntax of form specication les and report specication les is described in the INFORMIX-SQL Reference. The syntax of various command-line options is documented in Appendix H of the INFORMIX-SQL Reference.
Introduction
Syntax is illustrated in Informix documentation with the following kind of diagram, known as a railroad diagram. For example, this railroad diagram illustrates the syntax for the DATABASE statement of I-SQL:
DATABASE Section
DATABASE
database name
WITHOUT NULL INPUT
Refer to the Introduction in the INFORMIX-SQL Reference for a complete description of how to read a syntax diagram. Icons that appear in the left margin of the text indicate that the accompanying shaded text is valid only for some products or under certain conditions. In addition to the icons described in the preceding list, you may encounter the following icon in the left margin:
ANSI E/C
This icon indicates that the functionality described in the shaded text is valid only if your database is ANSI-compliant. This icon indicates that the functionality described in the shaded text is valid only if NLS features are active, as described in Appendix D of the INFORMIX-SQL Reference.
NLS
describe performance differences from earlier versions of Informix products and how these differences may affect current products. The le containing the Release Notes for I-SQL and other products is called TOOLS_6.0.
Please examine these les because they contain important information about application and performance issues.
I-SQL provides on-line Help; invoke Help by pressing CONTROL-W.
Introduction
msg_num
msg_num
Indicates the number of the error message to display. Error messages range from -1 to -32000. Specifying the - sign is optional.
You can specify up to 16 error messages per nderr command. nderr copies all the specied messages to standard output. For example, to display the -359 error message, you can enter either of the following:
finderr -359
or, equivalently:
finderr 359
The following example demonstrates how to specify a list of error messages. The example also pipes the output to the UNIX more command to control the display. You can also direct the output to another le so that you can save or print the error messages:
finderr 233 107 113 134 143 144 154 | more
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. The messages numbered -1 to -100 can be platform-dependent. If the message text for a message in this range does not apply to your platform, check the operating systems documentation for the precise meaning of the message number.
Introduction
NLS Support
Native Language Support (NLS) is supplied to meet the needs of European countries. This feature extends the ASCII character set from 128 to 256 characters. These additional characters allow you to include characters such as and in the denition of your database and in ACE and PERFORM. NLS also provides character sorting and comparison specic to particular languages, and region-specic monetary and numeric formatting. To use NLS, you need to set environment variables, as described in INFORMIX-SQL Reference Appendix D, Native Language Support Within INFORMIX-SQL.
Improved Performance
The removal of the relay module in the 6.0 engine results in improved speed in which data can be retrieved from and sent to a database. As a result, the performance of your I-SQL screens and reports that access a database should improve.
Introduction
Improved Quality
Over 100 bug xes have been made to this version of the product. Also, the documentation set has been completely reorganized, rewritten, and updated to include all 6.0 I-SQL features.
No support for effective checking of unique constraints No support for repeatable reads
Set the INFORMIXDIR environment variable so that I-SQL can locate its
programs.
Set the TERM environment variable so that I-SQL recognizes the kind of
terminal you are using.
Introduction
Set the PATH environment variable so that the shell searches the correct
bin for executable I-SQL programs. You can set these environment variables at the system prompt or in your .prole (Bourne shell) or .login (C shell) le. If you set these variables at the system prompt, you will have to assign them again the next time you log onto the system. If you set these variables in your .prole or .login le, the operating system assigns them automatically every time you log in. For more detailed information on environment variables, refer to Appendix B, Environment Variables, in the INFORMIX-SQL Reference. The following set of instructions assumes that I-SQL resides in the directory /usr/informix. If I-SQL has been installed in another directory, substitute the new directory name for /usr/informix. 1. Log onto the system. 2. Set the INFORMIXDIR environment variable. If you are using the Bourne shell, enter
INFORMIXDIR=/usr/informix export INFORMIXDIR
3. Set the TERM environment variable. To do this, you need to obtain the code for your terminal from the system administrator. If you are using the Bourne shell, enter
TERM=name export TERM
where name is the code for the terminal you are using. If you are using the C shell, enter
setenv TERM name
4. Set the TERMCAP or TERMINFO environment variable. If the code for your terminal is listed in the TERMCAP or TERMINFO les included with I-SQL, follow the instructions below. Otherwise, consult your system administrator about the procedure for your system.
10
Introduction
or
TERMINFO=/usr/informix/lib/terminfo export TERMINFO
or
setenv TERMINFO /usr/informix/lib/terminfo
5. Set the INFORMIXTERM environment variable. You can set this variable to termcap or terminfo, depending on which you are using to dene your terminal capabilities. If you are using the Bourne shell, enter
INFORMIXTERM filename export INFORMIXTERM
where lename is either termcap or terminfo. If you are using the C shell, enter
setenv INFORMIXTERM filename
If INFORMIXTERM is unset, I-SQL uses the termcap le. The use of termcap and terminfo les is described in detail in Appendix D, Modifying termcap and terminfo, in the INFORMIX-SQL Reference. 6. Include the directory containing I-SQL in your PATH environment variable. If you are using the Bourne shell, enter
PATH=$PATH:/usr/informix/bin export PATH
Introduction
11
7. If you placed these environment settings in your .login or .prole le, you should log out and then log back in. (This allows the shell to read the changes you have made.) The new settings take effect each time you log in. If you entered these environment settings from the system prompt, the new settings remain in effect until you log out. You will need to re-enter them every time you log onto the system. In addition to the environment variables listed in this section, you can assign other environment variables by following the instructions in Appendix B, Environment Variables, in the INFORMIX-SQL Reference.
The RETURN key is sometimes labeled RETURN or NEWLINE, or is marked with a bent arrow. It is located on the right side of the keyboard. The CONTROL key is often labeled CTRL or CONTROL and is located at the left of the keyboard. In this manual, it is called CONTROL. The [ ] key moves the cursor back one position on the screen. If your terminal does not have a [ ] key, use the CONTROL-H key.
CONTROL
LEFT ARROW
DOWN ARROW The [ ] key moves the cursor down one line. If your terminal does not have a [ ] key, use the CONTROL-J key. UP ARROW
The [ ] key moves the cursor up one line. If your terminal does not have an [ ] key, use the CONTROL-K key. screen. If your terminal does not have a [ ] key, use the CONTROL-L key.
RIGHT ARROW This key moves the cursor forward one position on the
DELETE
The DEL key is sometimes labeled RUBOUT, CANCEL, or DEL, and is referred to as DEL. On most systems the DEL key is used to cancel or abort a program, or leave a current menu and return to the menu one level above. The DEL key is referred to in this guide as the Interrupt key.
12
Introduction
CONTROL-C
On some systems, the CONTROL-C key is used to cancel or abort a program, or leave a current menu and return to the menu one level above. It is referred to in this manual as the Interrupt key. The BACKSPACE key may be labeled with a left-pointing arrow, and is usually located at the top right of the keyboard. The key is sometimes labeled ESC. The SPACEBAR is generally unlabeled.
BACKSPACE
ESCAPE SPACEBAR
integrity. You can control database and table privileges independently, allowing only selected individuals to access certain tables (or parts of tables) and excluding other users from the database entirely. The SQL statements used for these purposes are described in the Informix Guide to SQL: Tutorial, Version 4.1. For I-SQL to access a database, the current user must have execute (search) permission for each directory in the database pathname. Check with your system administrator for more information about operating system le and directory permissions.
operations directly so that performance is maximized. It is designed to handle the high performance requirements and integrity concerns of many large applications. Most applications can run on either engine because few differences affect the programmer. However, OnLine provides features that
Introduction 13
increase performance, extend available data types, and improve the administrative aspects of database management. The following features are available only with OnLine:
Raw disk I/O and optimized shared memory for greater performance High availability and automatic recovery Increased locking and process isolation options for greater integrity
control
Variable-length character data (VARCHARs) Binary Large OBjects (blobs) that can be any type or amount of data Distributed query capability across multiple databases Distributed query capability across multiple OnLine systems (optional)
I/O to raw storage devices and by tuning shared memory for maximum efciency. OnLine offers high data availability, which allows rapid recovery from system failures and provides you with logging choices, including the option of disk mirroring. OnLine provides advanced concurrency control by allowing you to set the level of locking granularity and the level of user process isolation.
OnLine supports three additional data types not available with INFORMIXSE. VARCHARs are variable-length character columns (up to 255 bytes) that use disk space only as it is needed. The TEXT and BYTE data types are Binary Large OBjects (blobs) capable of holding virtually any type or amount of data. TEXT can store ASCII text les with embedded control characters, such as documents generated through a word processor. BYTE can store any type of
binary data; such as spreadsheets, program load modules, digitized images, or voice patterns.
OnLine allows access to multiple databases on the same computer. You can
write applications that retrieve data from multiple tables, even if the tables reside in different databases. You can use the combined data for general display purposes or as input to a customized report. This manual provides you with information on how to use I-SQL with INFORMIX-SE. If you are planning to use OnLine, you can obtain more information about available data types from Appendix I, Using the INFORMIXOnLine Dynamic Server, in the INFORMIX-SQL Reference. You should refer to the INFORMIX-OnLine Dynamic Server Administrators Guide, Version 6.0, Version 6.0, for information about programming issues. Notes are placed at appropriate locations in this manual to help clarify where OnLine can provide additional functionality.
14 Introduction
Chapter
1
Introducing INFORMIX-SQL
Chapter Overview 3 3 What Is INFORMIX-SQL? What Is a Database? 4 How INFORMIX-SQL Stores Data 4 A Database is a Collection of Tables 5 Tables Are Made Up of Rows and Columns Retrieving Data from the Database 7 Searching for Rows 8 Searching for Columns 8 Searching for Columns Within Rows 8 Connecting Tables Through Column Joins 9 Getting Started with INFORMIX-SQL 11 6
The INFORMIX-SQL Main Menu 12 The Current Option 12 The Message Line 12 Moving the Highlight 13 Selecting an Option 13 What the Main Menu Options Mean Using the HELP Menu 16
13
The INFORMIX-SQL Facilities 16 Creating Tables with the Schema Editor 17 Using a Screen Form 18 The Report Writing Facility 20 Using a Structured Query Language 23 The User-Menu System 25 A Complete Database Management System 25
1-2
Introducing INFORMIX-SQL
Chapter Overview
This chapter introduces INFORMIX-SQL (I-SQL) and considers important database management concepts. The topics discussed include:
What is I-SQL What is a database What are tables, rows, and columns What is a relational database management system What is a screen form What is a report What is a database query
To make the best use of I-SQL, you must understand the basic concepts in this chapter. The section What Is a Database? is particularly helpful if you have had limited experience with computers or database management systems.
What Is INFORMIX-SQL?
I-SQL is a computer-based record-keeping system. As a database management system, I-SQL consists of useful programs or modules that perform data management tasks. I-SQL can substantially reduce the amount of time required to
organize, store, and retrieve information. It can summarize, group, and format information in a variety of helpful ways. You can use I-SQL to organize and store data, then view it in whatever format is useful to you. For example, you can store all the names, addresses, birthdays, and phone numbers of your friends, then use I-SQL to search through the database for all the Hunts, everyone with a birthday in March, all the Sutherlands on Cambridge Avenue with birthdays in May, and so on.
Introducing INFORMIX-SQL
1-3
What Is a Database?
What Is a Database?
A database is a collection of information or data. The telephone directory is a database; its data is the names, addresses, and telephone numbers of local residents and businesses. Other kinds of databases include:
The telephone directory is organized alphabetically by last name. If you want to call Jason Hunt, you look in the Last Name column under H. As long as you know the last name of the person you want to call, this scheme works. But what about nding phone numbers for everyone who lives on California Avenue? Or the phone number for someone whose last name you do not know? Since the telephone directory is not organized by street addresses or rst names, it would take a long time to nd these numbers. This is where I-SQL can help.
1-4
Introducing INFORMIX-SQL
What Is a Database?
The customer table contains information about the retail sporting goods
stores that purchase equipment from the distributor.
The stock table contains information about the items carried in stock by
the distributor.
The state table contains the names and postal abbreviations of the 50
states in the United States.
Introducing INFORMIX-SQL
1-5
What Is a Database?
Each row contains all the data about one of the objects the table describes. For example, in the stores demonstration database, the following is true:
Each row in the customer table contains all the information about one
retail customer.
Each row in the orders table contains all the information about one
purchase made by a retail sporting goods store.
Each row in the items table contains all the information about one item in
an order placed by a retail sporting goods store.
Each row in the stock table contains all the information about one of the
distributors products.
Each row in the manufact table contains all the information about one
manufacturer.
Each row in the state table contains all the information about one state in
the United States.
Each row in the cust_calls table contains information about one telephone
call from a customer.
Each row in the catalog table (OnLine only) contains information about
one of the items in stock. When you create a new table, it contains no rows. It consists only of the column names and contains no data. When you begin to store data in a table, you usually add one row at a time. Each table includes one or more columns. A column contains a particular type of information, such as a last name, order number, or zip code. When you create a database table, you assign a name to each column. These column names are similar to the headings that appear at the top of each column in a printed table. You use the column names to refer to the columns.
1-6
Introducing INFORMIX-SQL
What Is a Database?
For example, in the demonstration database, each row in the customer table contains 10 columns. The names of the columns and the information they contain are as follows:
This Column customer_num fname lname company address1 address2 city state zipcode phone Figure 1-1 Columns in the customer table Contains this Information Customer number Representatives rst name Representatives last name Name of store Store address, rst line Store address, second line City State Zip code Phone number
The gure that follows shows some of the data from the customer table, organized into rows and columns.
customer_num 101 102 103 104 105 Figure 1-2 fname Ludwig Carole Philip Anthony Raymond lname Pauli Sadler Currie Higgins Vector company All Sports Supplies Sports Spot Phils Sports Play Ball! Los Altos Sports address1 213 Erstwild Court 785 Geary St. 654 Poplar East Shopping Cntr 1899 La Loma Drive
Search for a particular row or group of rows Search for a particular column or group of columns Combine both of these techniques to search for specic columns in
specic rows Additionally, you can use a technique called joining to retrieve data from more than one table at a time. The ability to retrieve information from multiple tables is one of the many powerful facilities of I-SQL.
Introducing INFORMIX-SQL 1-7
What Is a Database?
All the information for the customer store named All Sports Supplies. Information for customers who have stores located in Redwood City. Information for customers who have stores located within the 94020 to
94040 zip code range. Each of these queries asks I-SQL to display all the information in one or more rows. Some database management systems call this type of query selection.
The names of all stores and the cities in which they are located All store names, addresses, and phone numbers The zip codes of all stores
Each of these queries looks for all values in a particular column or group of columns. Some database management systems call this type of query a projection.
The name and phone number of each customer in the city of San
Francisco. (I-SQL nds the name and phone number columns from the rows for customers located in San Francisco.)
The names of customers with stores in the 408 telephone area code. (I-SQL
nds the name columns from the rows for customers with telephone numbers beginning with the 408 area code.)
The name and address of the store that has been assigned customer
number 101. (I-SQL nds the name and address columns from the row of the store assigned customer number 101.) Each of these queries requests some, but not all, of the information stored in the customer table.
1-8 Introducing INFORMIX-SQL
What Is a Database?
system, a relational database management system lets you create direct relationships between tables when you query a database. With I-SQL, you do not need to duplicate the same information in different tables. Instead, you use a technique called joining to connect data from different tables. Joining lets you look at data stored in several tables as if it were all part of a single table. The stores demonstration database provides a good example of the use of joins. You might periodically want to print a list showing each customers name, address, and phone number, along with a list of each customers recent orders. You could do this by storing complete customer information, along with order information, in the orders table. Doing so, however, would make maintaining the database more time-consuming and prone to errors. The customer table contains information about the name, location, and phone number of each sporting goods customer. If you also stored this information in the orders table, you would have the name, location, and phone number stored in two separate tables. This means you would need to update both the customer and orders tables whenever a customer changed an address or a phone number. Entering the same data in two tables not only is inconvenient, it also creates greater opportunities for data-entry error. However, duplicate table information is unnecessary with I-SQL. You can obtain the list of recent customer orders more easily by joining tables. Tables can be joined if one column in each table contains the same (or similar) data. This column is called the join column, and you use it to create a temporary linkor joinbetween the tables. For example, the customer and orders tables both contain a customer_num (customer number) column. You can use this column as a join column. In the customer table, this column shows the unique customer number assigned to each sporting goods retailer. In the orders table, it shows which customer placed the order described in the row. By joining the two customer_num columns, you can obtain the desired list of customer name, address, and phone number (retrieved from the customer table) and orders (retrieved from the orders table) without duplicating information in the two tables. This joining process is illustrated in Figure 1-3 on page 1-10.
Introducing INFORMIX-SQL
1-9
What Is a Database?
customer_num 101 102 103 104 order_num 1001 1002 1003 1004 Figure 1-3
fname Ludwig Carole Philip Anthony order_date 01/20/1991 06/01/1991 10/12/1991 04/12/1991
lname Pauli Sadler Currie Higgins customer_num 104 101 104 106
c u
The row in the customer table with information about Anthony Higgins contains the number 104 in the customer_num column. The orders table also contains a customer_num column that stores the number of the customer who placed a particular order. According to Figure 1-3, customer 104 (Anthony Higgins) placed two orders, since his customer number appears in two rows in the orders table. One of the most important features of a truly relational database management system is the ability to join data from different tables. Instead of storing identical data in several tables, a relational database management system lets you retrieve data from several tables at once and display it as if it were stored in a single table. Joining lets you rearrange your view of a database whenever you want. This exibility lets you create new relationships between tables without redesigning your database. You can easily expand the scope of a database by adding new tables that join existing tables. The seven tables of the stores demonstration database (or eight tables if you are using OnLine) are linked together by potential join columns, as shown in the next gure.
items orders order_num cust_calls customer_num call_dtime user_id call_code call_descr res_dtime res_descr state code sname customer customer_num fname lname company address1 address2 city state zipcode phone order_date customer_num ship_instruct backlog po_num ship_date ship_weight ship_charge paid_date item_num order_num stock_num manu_code quantity total_price stock stock_num manu_code description unit_price unit unit_descr
(OnLine Only) catalog catalog_num stock_num manu_code cat_descr cat_picture cat_advert manufact manu_code manu_name lead_time
Figure 1-4
Join relationships in the stores demonstration database (potential join columns shaded)
Appendix A, The Demonstration Database and Application in the INFORMIX-SQL Reference includes a section discussing the join columns that link the tables in the demonstration database.
This operation displays the I-SQL Main menu as described in the next section.
Introducing INFORMIX-SQL 1-11
The I-SQL Main menu displays a series of options across the top of the screen. These options represent the major I-SQL functions.
describes the activities available to you when you select the Form option on the I-SQL Main menu. You can
Run an existing form. (Use a screen form to enter or retrieve data.) Modify an existing form. (Alter the appearance or behavior of the screen
form.)
If you cannot remember what an option does, just highlight it and read the message.
Selecting an Option
Once you have highlighted the option you want, you can select it by pressing the RETURN key. Pressing RETURN tells I-SQL you want to work with the option selected. For example, if you want to select, create, or drop a database, move the highlight to the Database option and press RETURN. You also can select an option by typing the rst letter of its name. Typing the rst letter selects the option right away; you do not have to move the highlight or press RETURN. For example, no matter where the highlight appears on the Main menu, you can always select the Exit option by pressing the e key.
Report
Query-language
information to a database, and change the structure of a database. See Chapter 7, Using SQL, for details. User-menu Displays the USER-MENU menu. Use this menu to work with custom screen menus. These menus are created through the procedures described in Chapter 5, UserMenu, in the INFORMIX-SQL Reference. Displays the DATABASE menu. Use this menu to select, create, or drop a database. Displays the TABLE menu. Use this menu to create or alter a table. Exits I-SQL and returns to the operating system.
Form
Run Modify Generate New Compile Drop Exit
Report
Query-Language
User-Menu
Database
Table
use a form to enter data or query a database modify a form specication generate a default form create a new form specication compile a form drop a form from the database return to the INFORMIX-SQL Main menu Run Modify Exit run the user-menu for the current database modify the user-menu for the current database return to the INFORMIX-SQL Main menu
display a report change an existing report specication generate a default report specication based on a database table create a new report specication compile a report specication drop a report return to the INFORMIX-SQL Main menu New Run Modify Use-editor Output Choose Save Info Drop Exit
select an existing database create a new database drop an existing database exit to the INFORMIX-SQL Main menu
enter new SQL statements run the current SQL statements modify the current SQL statements use a system editor to modify the current SQL statements send the results of the current SQL statements to the screen or a le choose a le that contains SQL statements and make those statements the current statements save the current SQL statements in a le so you can use them again later display information about the current database drop an INFORMIX-SQL command le return to the INFORMIX-SQL Main menu Create Alter Info Drop Exit create a new table alter the structure of an existing table give information about the structure of a table drop a table from the database exit to the INFORMIX-SQL Main menu
Figure 1-5
You can read as much or as little text as you need. Selecting the Screen option on the HELP menu displays the next page of the HELP text; selecting the Resume option lets you continue your work. You use the HELP menu in the same way you use other I-SQL menus. Press the SPACEBAR or arrow keys to move the highlight to the option you want and then press RETURN. You also can enter the rst letter of an option.
Create and modify tables using the menus provided with the schema editor Enter and retrieve database information using screen forms Sort, combine, format, and display data with reports Enter, modify, and retrieve database information using the query language Access I-SQL through special-purpose, custom menus
A schema is essentially a blueprint for a table. Just as a blueprint of a building provides instructions for constructing the building, a table schema denes the structure of a database table. The dbschema utility lets you reproduce a table schema. For a detailed description of this utility, see Informix Guide to SQL: Reference, Version 6.0 or refer to the Administrators Guide for your database server. The nished table schema for the customer table (included in the demonstration database) appears as follows:
CREATE TABLE customer : Add Modify Drop Screen Exit Adds columns to the table above the line with the highlight. ----- Page 1 of 1 ----- mydata -------------- Press CONTROL-W for Help -------Column Name customer_num fname lname company address1 address2 city state zipcode phone Type Serial Char Char Char Char Char Char Char Char Char Length 101 15 15 20 20 20 15 2 5 18 Index Unique Nulls No Yes Yes Yes Yes Yes Yes Yes Yes Yes
Dups
Introducing INFORMIX-SQL
1-17
[ [ [ [ [
Last Name: ] ]
City : Telephone :
] ]
State :
Zip :
_______________________________________________________________________________ _______________________________________________________________________________
You add data to a table by entering it into the elds on a form. Each eld normally corresponds to a column in one of your database tables. The data you enter into a eld is stored in the corresponding column.
You can also use a screen form to query the database and retrieve information. For example, to nd the rows for all customers with stores in Redwood City, you would complete the customer form as follows:
QUERY: ESCAPE queries. INTERRUPT discards query. ARROW keys move cursor. Searches the active database table. ** 1: customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [ ]
[ [ [ [Redwood City [
] ] ] ] ]
Last Name:
City : Telephone :
State :
Zip :
_______________________________________________________________________________ _______________________________________________________________________________
This screen instructs I-SQL to search for rows in which the city column contains Redwood City. Here is what the customer form looks like when you execute the query:
PERFORM: Query Next Previous View Add Update Remove Table . . . Searches the active database table. ** 1: customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [104 Play Ball! [Anthony ]
Last Name:
[Higgins
[East Shopping Cntr. ] [422 Bay Road ] [Redwood City [415-368-1100 ] ] State : [CA] Zip : [94026]
City : Telephone :
_______________________________________________________________________________ _______________________________________________________________________________
5 row(s) found
Introducing INFORMIX-SQL
1-19
The message at the bottom of the screen indicates that I-SQL found ve customers with locations in Redwood City. The data about the rst customer appears on the screen.
Mailing labels Form letters Payroll summaries Medical histories Accounting records Inventory lists Telephone directories Project schedules Sales and marketing reports Payroll checks
The demonstration database application materials include a variety of reports illustrating the uses of the I-SQL report writing facility.
Last Name
Company
City
Vector Lawson
Beatty Grant
Watson Parmelee
Baxter
Oakland
Currie Ream
Sadler
Sports Spot
San Francisco
18
Figure 1-6
The preceding report lists the last name, company, and city for all customers. It groups customers by city and calculates the total number of customers. You also can prepare interactive reports with I-SQL. The next report asks the user for beginning and ending dates and prepares a listing of daily orders. It then automatically computes and prints subtotals and totals.
==================================================== DAILY ORDER REPORT ==================================================== FROM: TO: 01/01/94 03/30/94 RUN DATE: RUN TIME: 08/20/94 16:20:54
NUMBER 1001
==================================================== ====================================================
$2,495.00
Figure 1-7
Creating and dropping tables Entering and deleting data Querying a database Renaming tables and columns
To use SQL, you enter one or more SQL statements. A statement is simply an instruction that tells I-SQL what you want to do. For example, to create a table, you use the CREATE TABLE statement; to query a database, you use the SELECT statement. Here is the statement that was used to create the stock table in the demonstration database:
create table stock ( stock_num manu_code description unit_price unit unit_descr smallint, char(3), char(15), money(6), char(4), char(15)
);
This statement tells I-SQL to create a table named stock and species the name of each column and the type of data (numbers, words, money, or dates) each column will contain. Column names appear on the left; data types are indicated on the right.
Introducing INFORMIX-SQL
1-23
The next example illustrates how database queries are easily achieved with SQL. In this example, all stock items relating to the sport of baseball are selected from the database, and a ve percent increase in their unit price is calculated.
select stock_num, stock.manu_code, manu_name, description, unit_price, unit_price * 1.05 newprice from stock, manufact where stock.manu_code = manufact.manu_code and description matches "baseball*" order by stock.manu_code
----------------------- stores2 ------------ Press CONTROL-W for Help ---------stock_num manu_code manu_name 1 2 1 3 1 HRO HRO HSK HSK SMT Hero Hero Husky Husky Smith description baseball baseball baseball baseball baseball gloves gloves bat gloves unit_price $250.00 $126.00 $800.00 $240.00 $450.00 newprice $262.5000 $132.3000 $840.0000 $252.0000 $472.5000
5 row(s) retrieved.
Submenus on the custom menu system I-SQL programs, such as reports, screen forms, and SQL queries Other programs or sets of programs in your software library Operating system utilities
The main level of the user-menu included with the demonstration database application materials appears below:
WEST COAST WHOLESALERS, INC. 1. FORMS 2. REPORTS 3. QUERIES 4. TABLE DEFINITIONS 5. UTILITIES
Use space bar, arrow keys, or type number to make selection. Enter e to return to previous menu or exit. Press the RETURN key to execute selection: 1
Introducing INFORMIX-SQL
1-25
Chapter
Creating a Database
Chapter Overview 3 Two Ways to Create Databases and Tables 3 Using the Main Menu to Create Databases and Tables 4 Using SQL to Create Databases and Tables 4 Accessing INFORMIX-SQL 4
Using the Main Menu to Create a Database 5 Guidelines for Selecting Database Names 7 The Current Database 7 System Files That Make Up a Database 8 Selecting a Different Current Database 8 Leaving a Current Menu or Screen 9 Using the Main Menu to Create a Table 9 Naming the New Table 11 Using the CREATE TABLE Menu 11 An Overview of Building a Table 12 Naming the Columns 13 Assigning Data Types 14 CHAR Columns 15 Number Columns 15 SERIAL Columns 16 DATE Columns 17 MONEY Columns 17 DATETIME Columns 17 INTERVAL Columns 18 Assigning a Data Type to the Column 18 Creating Indexes 19 NULL Values 21
Adding the Remaining Columns to the Table Exiting the Schema Editor 22 System Files 23 Changing the Table Specications 24
21
2-2
Creating a Database
Chapter Overview
This chapter explains how to use INFORMIX-SQL (I-SQL) to set up a database and describes how to create both a table and an index. The following topics are discussed:
How to create a database How to identify the current database How to create a table What are data types How to modify the structure of a table When to create an index How to create an index What are NULL values
Before you can store data using I-SQL, you must create a database and one or more tables. If you intend to use only databases that someone else has created, you can skim this chapter. Otherwise, read it carefully, for it contains important information that you will need to set up your own databases with I-SQL. If you have not already done so, create the demonstration database as described in Appendix A, The Demonstration Database and Application, in the INFORMIX-SQL Reference.
Creating a Database
2-3
Accessing INFORMIX-SQL
tables.
SQL is a set of English-like statements you can use to perform the following
functions:
Create and drop tables and indexes Enter and delete data Query a database Select a different current database Display information about one or more tables Rename tables and columns Check and repair tables by passing these functions to the server Grant and revoke database and table privileges
For complete information about the SQL statement syntax and usage, see Informix Guide to SQL: Syntax, Version 6.0.
Accessing INFORMIX-SQL
Before working with I-SQL, be sure that your computer is running properly and that the operating system prompt appears on the screen. Then enter:
isql
2-4
Creating a Database
Exit
Creating a Database
2-5
Four options appear on the DATABASE menu. Select Create Drop Exit Selects an existing database Creates a new database Drops an existing database Exits to the I-SQL Main menu
The CREATE DATABASE screen appears and prompts you to name the new database.
CREATE DATABASE >> Enter the name you want to assign to the new database, then press RETURN. ------------------------------------------ Press CONTROL-W for Help ------------
Type the new database name (this chapter uses mydata) and press RETURN. You can assign any name you want, as long as you follow the guidelines below. If you accidentally enter the name of an existing database, I-SQL displays the message
330: Cannot create database.
2-6
Creating a Database
Number of Characters
The name you assign to the database can be up to 10 characters long. If you store more that one database in a directory, each database name must be unique.
Reserved Words
Certain reserved words might cause ambiguities when used as names of tables, columns, databases, or other identiers. See Appendix F, Reserved Words, in the INFORMIX-SQL Reference.
Creating a Database
2-7
NLS
Certain kinds of database connection attempts are rejected by the server if you are using Native Language Support. For more information refer to Appendix C, Native Language Support in INFORMIX-SQL, in the INFORMIX-SQL Reference.
The database directory initially contains 22 les. The les are associated with the system catalog tables. I-SQL uses the system catalog tables to keep track of the tables, columns, indexes, views, synonyms, and permissions in each database. The system catalog tables are described in detail in Chapter 2, System Catalog, in Informix Guide to SQL: Reference, Version 4.1.
2-8
Creating a Database
To select a different database, move the highlight to the Select option and press the RETURN key, or type s. The SELECT DATABASE screen appears.
SELECT DATABASE >> Select a database with the Arrow Keys, or enter a name, then press RETURN. ----------------------- mydata ---------------- Press CONTROL-W for Help -------mydata stores2
You select a database by typing its name or by using the Arrow keys to move the highlight to the name of the database you want. Press RETURN, and the name you typed or highlighted becomes your current database. For example, to select the stores2 database in the previous menu, type or highlight stores2, and then press RETURN. To leave the SELECT DATABASE screen without selecting a new database, press the Interrupt key (CONTROL-C). Exit the DATABASE menu by typing or highlighting exit, or by simply typing e.
Any tables created by I-SQL are placed in the current database. Before you create a table, be sure that the current database is the one in which you want the table to exist. The name of the current database is displayed on the third line from the top of the screen. The following examples indicate you are working with the mydata database; this is reected in the status line that appears at the top of the screen. If mydata is not your current database, use the options available with the DATABASE menu and select (or create) mydata. To begin creating a table, select the Table option on the I-SQL Main menu. The
TABLE menu appears:
Info
Drop
Exit
The TABLE menu displays ve options: Create Alter Info Drop Exit Creates a new table Alters the structure of an existing table Gives information about the structure of a table Drops a table from the database Exits to the I-SQL Main menu
You must follow the same guidelines that apply to database names (see the section entitled Guidelines for Selecting Database Names on page 2-7) except that table names can be up to 18 characters long. Enter a table name (this chapter uses the name clients) and press RETURN. I-SQL displays the CREATE TABLE menu.
The CREATE TABLE menu displays ve options: Add Modify Drop Screen Exit Adds a new column to the table Modies the structure of an existing column Drops an existing column from the table Scrolls down the screen and displays new text Exits to the TABLE menu
Creating a Database
2-11
Correcting Mistakes
If you make a mistake when entering information about a column, you can back up and correct it as long as you are still dening the same column (still working on the same line). Use the [ ] and [ ] keys to move the highlight back and forth under the headings. If you notice a mistake in one table column after you have moved on to another, refer to the section Changing the Table Specications on page 2-24.
After you have nished building a schema for the clients table, the screen will appear as follows:
CREATE TABLE clients : Add Modify Drop Screen Exit Adds columns to the table above the line with the highlight. ----- Page 1 of 1 ----- mydata ----------------- Press CONTROL-W for Help -------Column Name customer_num fname lname company address1 address2 city state zipcode phone Type Serial Char Char Char Char Char Char Char Char Char Length 101 15 15 20 20 20 15 2 5 18 Index Nulls Unique No Yes Yes Yes Yes Yes Yes Yes Dups Yes Yes
The clients table created in this chapter is identical to the customer table included in the stores demonstration database.
In selecting column names, you must follow the same guidelines that apply to table names (see the section Naming the New Table on page 2-11). You must use a different name for each column within a single table so that I-SQL can identify each column uniquely. Enter customer_num for the column name and press the RETURN key.
Creating a Database 2-13
----- Page 1 of 1 ----- mydata ----------------- Press CONTROL-W for Help -------Column Name customer_num Type Length Index Nulls
You can store many different types of data in a table: dates, zip codes, names, part numbers, part descriptions, salaries, coststhe list is endless. You need to choose the data type that best suits each type of data. The data type indicates the kind of information you intend to store in each column. Character Number
CHARACTER columns store any combination of letters, numbers, and symbols.
Number columns store six different data types (including the SERIAL type described below). Each is designed to store a different kind of number data.
SERIAL columns store sequential integers assigned by I-SQL.
time.
INTERVAL columns hold values that represent a span of
time. You cannot use BYTE and TEXT data types with the INFORMIX-SE database server. You can use these data types only with OnLine. For information on using BYTE and TEXT data types with OnLine, see Appendix I, Using the INFORMIX-Online Dynamic Server, in the INFORMIX-SQL Reference.
CHAR Columns
CHAR (short for CHARacter) columns store any combination of letters, numbers, and symbols. You normally use CHAR columns to store names, addresses, social security numbers, job titles, project names, and other information that combines letters, numbers, and symbols.
You must specify the length of each CHAR column. This length is the total number of characters you want to reserve for the name, address, job title, or whatever data you wish to store in the column.
CHARACTER is a synonym for CHAR. You can use CHARACTER in place of CHAR anytime you need to specify the CHAR data type.
Number Columns
There are six data types for numbers. Each type is designed for a different kind of number. You cannot store characters or symbols in any number column, but you can use plus signs (+) and minus signs (-) to show whether numbers are positive or negative. To indicate a number data type, choose Number when prompted by the ADD TYPE menu. When you specify a number data type, I-SQL displays the ADD NUMBER menu and asks you for the exact data type. A summary of the number data types follows. The SERIAL data type is described separately in the next section.
DECIMAL Columns
DECIMAL data types are numbers with denable precision and scale.
To use a DECIMAL data type, choose Decimal when the ADD NUMBER menu appears. You can then stipulate the precision and scale. The total number of digits you want the decimal to hold is the precision, and the number of digits after the decimal point is the scale. For example, the phrase (6,2) indicates that the column stores six-digit numbers, with four digits before the decimal point and two after the decimal point. Specifying the precision and scale is optional.
DECIMAL has two synonyms, DEC and NUMERIC. While neither DEC nor NUMERIC appear on the ADD NUMBER menu, you can use them in place of DECIMAL in the CREATE TABLE statement.
Creating a Database
2-15
To use these data types, enter Smallint or Integer when the ADD NUMBER menu appears.
INT is a synonym for INTEGER. INT does not appear on the ADD NUMBER menu, but you can use it in place of INTEGER in the CREATE TABLE
statement.
columns do not store larger numbers; they store numbers with greater precision. To use these data types, choose Smalloat or Float when the ADD NUMBER menu appears.
REAL is a synonym for SMALLFLOAT, and DOUBLE PRECISION is a synonym for FLOAT. While neither synonym appears in the ADD NUMBER menu, you can use REAL in place of SMALLFLOAT, or DOUBLE PRECISION in place of FLOAT in the CREATE TABLE statement.
SERIAL Columns
Serial numbers ensure that a sequential number is assigned to each row of the table. You do not need to enter data in a SERIAL column. Each time you add a new row to a table, I-SQL automatically assigns the next number, in sequence, to the SERIAL column. Normally, the starting number is one, but you can select any number greater than zero as your starting number. The highest serial number I-SQL can assign is 2,147,483,647. Once I-SQL assigns a SERIAL number, you cannot change it. (If you were allowed to change the number, I-SQL could not guarantee uniqueness.) Each table in a database can contain only one SERIAL column. To create a SERIAL column, choose Serial from the ADD TYPE menu in the CREATE TABLE schema.
When you specify a SERIAL data type, I-SQL displays the ADD STARTING NUMBER screen and asks you for the starting number. You can select any starting number greater than zero. Do not enter a comma in the number you select. For example, you would enter 62000 to start the numbering at 62,000.
DATE Columns
Use the DATE data type for columns that store calendar dates. A DATE column holds a date in the form mm/dd/yyyy where mm is the month (1-12), dd is the day of the month (1-31), and yyyy is the year (0001-9999).
DATE value 05/02/1985 09/08/1883 12/25/1900 Meaning May 2, 1985 September 8, 1883 December 25, 1900
To create a DATE column, choose Date from the ADD TYPE menu in the CREATE TABLE schema.
MONEY Columns
MONEY columns store currency amounts.
To create a MONEY column, choose Money from the heading on the ADD TYPE menu. I-SQL displays the ADD LENGTH screen and prompts you for the length (precision) of the MONEY column. Type the length (total number of digits that the MONEY column will accommodate), then press the RETURN key. You then see the ADD SCALE screen. Type the number of digits that should appear to the right of the decimal point and press the RETURN key.
DATETIME Columns
A DATETIME column holds a value that represents a moment in time. It can indicate any time value from a year through a fraction of a second. You establish the precision of the DATETIME column when you create the column. To create a DATETIME column, choose date-Time from the heading on the ADD TYPE menu. I-SQL displays the ADD DATETIME QUALIFIER rst-TO-last screen and prompts you for the precision of the DATETIME column. Select rst, then select last.
Creating a Database
2-17
INTERVAL Columns
Use the INTERVAL data type for columns in which you plan to store values that represent a span or period of time. An INTERVAL value can represent a span of years and months, or it can represent a span of days through a fraction of a second. You establish the precision of the INTERVAL column when you create the column. To create an INTERVAL column, choose Interval from the heading on the ADD TYPE menu. I-SQL displays the ADD INTERVAL QUALIFIER rst(n)-TO-last screen and prompts you for the precision of the INTERVAL column. When you select rst, I-SQL prompts you again for the precision of rst.
----- Page 1 of 1 ----- mydata ----------------- Press CONTROL-W for Help -------Column Name customer_num Type Length Index Nulls
The customer_num column contains the customer number for each store. Data type SERIAL is appropriate for this column because you want to ensure that a unique number is assigned to each customer. Type s for serial, and I-SQL displays the ADD STARTING NUMBER screen.
ADD STARTING NUMBER >> Enter the starting number.
----- Page 1 of 1 ----- mydata ----------------- Press CONTROL-W for Help -------Column Name customer_num Type Serial Length 1 Index Nulls Unique No
I-SQL displays the SERIAL data type under the Type heading of the schema and, because you are describing a SERIAL column, asks you for the number I-SQL should begin with when assigning numbers. I-SQL automatically starts assigning SERIAL numbers at the number 1. If you want a different starting number, indicate it at this time; otherwise, press RETURN to select the default.
two sections.) Assign the SERIAL data type to complete the denition of the customer_num column. The highlight moves down a line and to the left, the ADD NAME menu appears, and you can begin dening the next column.
ADD NAME >> Enter column name.
----- Page 1 of 1 ----- mydata ---------------- Press CONTROL-W for Help -------Column Name customer_num Type Serial Length 101 Index Nulls Unique No
Creating Indexes
It helps I-SQL nd information more quickly if you create indexes for the columns in a table. However, just as you can nd information in a book without consulting the index, I-SQL can nd information in a database even if you do not index any columns. In fact, if there is only one table in your database, you probably will not need any indexes until you have entered several hundred rows of data into the table. Placing too many indexes on a table has the undesired effect of slowing down the system. As your database increases in size and your database needs change, you can always add and delete indexes. A detailed discussion of indexes and indexing strategies is contained in Informix Guide to SQL: Reference, Version 4.1.
Creating a Database
2-19
Indexing Guidelines
Indexing choices depend on how you use your database. In general, you do not need to create an index on a column until one or more of the following conditions exists:
A table contains at least 200 rows. A column is used in a join operation. A column is regularly used in searches or sorts.
What You Can Index
You can create an index that applies to a single column or to several columns as a group.
Sometimes, you might want to prevent users from entering duplicate information in an indexed column. If you create a column to store social security numbers, you probably want to prevent duplicate entries. To do that, choose no on the ADD DUPLICATES menu. You also can prevent duplicate entries by placing a UNIQUE CONSTRAINT on a column when issuing a CREATE TABLE statement. For details, see the description of the CREATE TABLE statement in Chapter 6 of Informix Guide to SQL: Reference, Version 4.1.
2-20 Creating a Database
Clustered Indexes
Because the operating system extracts information from the disk in blocks, the more rows that are physically on the same block and are already in the same order as an index, the faster an indexed retrieval proceeds. You can cause the physical order in the table to be the same as the order in an index through clustering. See the CREATE INDEX statement in Chapter 6 of Informix Guide to SQL: Reference, Version 4.1 for more information.
NULL Values
I-SQL lets you identify columns in which NULL values are allowed. The purpose of NULL values in a database is to indicate when no value is assigned to a particular column in a particular row of a table. The reasons for not having assigned a value could include not knowing the correct value or that no value yet exists. The NULL also might indicate that no value is appropriate for a given column because of the values that were entered in other columns.
For example, consider entering data for a bank customer who is requesting a loan. If the customer is not employed, the employer column in the banks customer table will not contain an entry for this person. This CHAR column has the value NULL. A hire_date column in the same table is meaningless in this case. There is no appropriate date to enter, thus the value is NULL.
Creating a Database
2-21
Column Name fname lname company address1 address2 city state zipcode phone
Type char char char char char char char char char
Length 15 15 20 20 20 15 2 5 18
Index no no no no no no no duplicates no
Nulls yes yes yes yes yes yes yes yes yes
The schema for the clients table is now complete. Select the Exit option and I-SQL displays the EXIT menu:
EXIT clients: Build-new-table Discard-new-table Builds a new table and returns to the Table Menu. ----- Page 1 of 1 ----- mydata ---------------- Press CONTROL-W for Help -------Column Name customer_num fname lname company address1 address2 city state zipcode phone Type Serial Char Char Char Char Char Char Char Char Char Length 101 15 15 20 20 20 15 2 5 18 Index Nulls Unique No Yes Yes Yes Yes Yes Yes Yes Dups Yes Yes
The EXIT menu displays two options: Build-new-table Discard-new-table Builds the table Discards the table instructions
System Files
For each table you create, I-SQL creates two system les. I-SQL stores these les in the same directory as the system catalogs and names them with the rst several characters of the name of the table, a unique number starting at 100, and the following extensions:
.dat .idx This file contains table data. This file contains table indexes.
When you use the operating system command to list the contents of the mydata.dbs directory, you see the names of these les along with the names of the system catalogs. Do not do anything with these les; I-SQL uses them to keep track of the information in the table, and if you delete them, you also delete your table.
Creating a Database
2-23
The Alter option on the TABLE menu is described in detail in the section Changing the Structure of a Table on page 9-5.
Chapter
Entering Data
Chapter Overview 3 4 What Is a Screen Form? 3 Screen Forms in the Demonstration Database What Is PERFORM? 5 Including Data from Multiple Tables 5 Each Table Can Contribute to Several Forms Using a Screen Form 6 Choosing the Form You Want The PERFORM Screen 8 Information Lines 8 Screen Form 9 Status Lines 10 The PERFORM Menu Options 10 7
Adding Data to a Database 12 Entering Data in the Fields 13 Number Fields 13 Character Fields 13 Date Fields 14 Money Fields 14 Datetime Fields 14 Interval Fields 15 Conrming Your Entry 15 Data Checking in PERFORM 15 Special Functions 16 Positioning the Cursor 16 Field Editing 17 Using the Multiline Editor 18 Storing the Row 18
18
3-2
Entering Data
Chapter Overview
This chapter explains how to enter and store data in an INFORMIX-SQL (I-SQL) database. The topics discussed include
What is a screen form What are elds What are eld delimiters How to add a new row to a table How to change an existing row in a table How to delete a row from a table
This chapter covers important features that you should be familiar with before going on to Chapter 4, Querying a Database, in this manual. For complete information about entering data on a screen form, refer to Chapter 3, The PERFORM Screen Transaction Processor, in the INFORMIXSQL Reference.
Entering Data
3-3
[ [ [ [ [
Last Name: ] ]
City : Telephone :
] ]
State :
Zip :
_______________________________________________________________________________ _______________________________________________________________________________
You add data to a table by entering it in the elds on a form. Each eld normally corresponds to a column in one of the database tables. The data you enter in a eld is stored in the corresponding column. The correspondences between elds and columns are specied when the form is created. For example, the Company eld on the customer form corresponds to the company column in the customer table. Whatever you enter in the Company eld is stored in the company column in the customer table. Fields presented on the screen are surrounded by brackets [ ] called delimiters. You can specify different delimiters when you create a form if you do not want to use the brackets. You normally include a descriptive label alongside each eld to indicate what data is in the eld. For example, the customer form contains labels like Customer Number and Name. You can include horizontal and vertical lines in your form. You also can use special graphics characters to draw boxes around elds on a form. The customer form demonstrates the use of horizontal lines.
3-4
Entering Data
What Is PERFORM?
Fields can be displayed in reverse video and in color. The Company eld in the customer form appears in reverse video. A form might be one or several pages long. If a form includes more data than can t comfortably on a single screen, you can split the form over several screen pages. If your screen is longer than the standard 24 lines, you can size your form to the actual screen size.
What Is PERFORM?
When you use a screen form, you are using a feature of I-SQL called PERFORM. You can access PERFORM from the I-SQL Main menu. Because it is a separate program, you also can access it directly from the operating system. For information on accessing programs from the command line, refer to Appendix H in the INFORMIX-SQL Reference.
Entering Data
3-5
To use a screen form, select the Run option on the FORM menu. PERFORM displays the RUN FORM screen and a list of available forms.
3-6
Entering Data
Choose the form you want by highlighting its name with the Arrow keys and then pressing RETURN. If you prefer, you can type the name of the form and then press the RETURN key. The examples in this chapter use the customer form and the stores demonstration database. To select the customer form, position the highlight on customer and press the RETURN key.
Entering Data
3-7
[ [ [ [ [
Last Name: ] ]
City : Telephone :
] ]
State :
Zip :
_______________________________________________________________________________ _______________________________________________________________________________
The PERFORM screen is divided into three sections: information lines, the screen form, and status lines.
Information Lines
The PERFORM menu appears on the top two lines of the screen (also called information lines). The rst line displays a list of menu options; the second line describes the current option and indicates the number and name of the active database table. This is how the PERFORM menu initially appears:
PERFORM: Query Next Previous View Searches the active database table. Add Update Remove Table . . . ** 1: customer table**
3-8
Entering Data
PERFORM assigns a number to each table contributing data to the screen form; if there are three tables, PERFORM numbers them 1, 2, and 3. In the
sample gure, the customer table is both table 1 and the active table. You can create an alias for the table name in your form. When you do so, the second information line shows the alias you select rather than the original table name. Here the customer table is aliased as c:
PERFORM: Query Next Previous View Searches the active database table. Add Update Remove Table ** 1: c table** . . .
For more information on using aliases, see Chapter 2, The FORMBUILD Transaction Form Generator, in the INFORMIX-SQL Reference.
Screen Form
The middle section of the screen displays the form you select, in this case the customer form:
[ [ [ [ [
] ] ] ] ]
Last Name:
City : Telephone :
State :
Zip :
_______________________________________________________________________________ _______________________________________________________________________________
Entering Data
3-9
Status Lines
PERFORM uses the last two lines of the screen to display error messages, as
Note: The number of options that appear on the rst menu page depends on the character capacity of your screen. The two-page screens displayed here demonstrate a monitor with an 80-character screen. Terminals with a larger character capacity show more options on the rst menu page.
The ellipsis (. . .) at the end of the rst line of the screen indicates that additional menu items are available on the second page of the menu. Move the highlight past the Table option to display the second menu page. The second menu page is illustrated here:
PERFORM: . . . Screen Current Master Shows the next page of the form. Detail Output Exit ** 1: customer table**
The ellipsis on the second menu page indicates that additional items are available on the previous menu page. Use the SPACEBAR or the Arrow keys to move the highlight to the menu options. When you move the highlight past the rst or last menu option on a page, the alternate menu page appears. The [ ] moves the highlight to the left and, after the rst item, moves the highlight to the last item on the alternate page. The [ ] and [ ] move the highlight to the rst item on the alternate page. The [ ] moves the highlight to the right and, after the last item, moves the highlight to the rst item on the alternate page. You select an option in one of two ways:
Position the highlight on a menu option and press RETURN. Type the rst letter of the option name, regardless of whether the option
appears on the current menu page. The Add, Update, Remove, and Exit options are discussed in detail in this chapter. The Query, Next, and Previous options are briey mentioned in this chapter and are discussed in further detail in Chapter 4, Querying a Database. The Screen and Output options also are discussed in Chapter 4. The View option displays the contents of a eld of data type TEXT or BYTE, and applies to the INFORMIX-OnLine Dynamic Server only. See Appendix I in the INFORMIX-SQL Reference for information on using this feature. The remaining options are explained in Chapter 5, Using Multiple-Table Forms.
Entering Data
3-11
Note: Complete information about Informix data types appears in the Informix Guide to SQL: Tutorial, Version 4.1, and in Chapter 3, Data Types, in the Informix Guide to SQL: Reference, Version 4.1.
OL
OnLine also supports TEXT, BYTE, and VARCHAR data types in forms.
Number Fields
Number elds correspond to SMALLINT, INTEGER, SMALLFLOAT, FLOAT, DECIMAL, or SERIAL columns. You can enter only numbers in number elds. You must enter the correct type of number in each number eldintegers in INTEGER elds, oating-point numbers in FLOAT elds, and so on.
PERFORM automatically assigns values to SERIAL elds when you add data to a database. You cannot enter numbers in SERIAL elds and, once I-SQL
assigns a serial number, you cannot change it. As you enter data on the customer form, notice that the cursor does not move into the Customer Number eld because the corresponding column in the customer table is a SERIAL eld. PERFORM displays a serial number in the Customer Number eld when you conrm the data you have entered by pressing the ESCAPE key.
Character Fields
Character elds in PERFORM correspond to CHAR columns in a database table. You can enter letters, numbers, and symbols in character elds. You can enter as many characters as you can t in the eld.
Entering Data 3-13
A character eld is normally the same length as the CHAR column to which it corresponds. However, if the eld is longer than the column, you might occasionally enter more characters than the column can hold. If you do, PERFORM stores as many characters as it can and displays a message indicating that some of the characters you entered have not been stored.
Date Fields
Enter calendar dates in date elds in the form [mm]m[d]d[yy]yy, with any nonnumber characters as optional dividers between the month, day, and year. For example, you could enter August 4, 1994, in any of these ways:
Aug 4 1994 08/04/94 8.4.94 08 04 1994
(If you enter a two-digit year, PERFORM assumes it is a year in the 1900s.) After you press RETURN, PERFORM displays the date in the format specied in the instructions used to create the form.
Money Fields
Enter dollars-and-cents amounts in money elds. PERFORM displays money amounts with a dollar sign and decimal point. When you enter data in a money eld, do not enter a dollar sign or comma. To enter four thousand dollars in a money eld, type either of the following:
4000 4000.00 PERFORM displays $4000.00.
Datetime Fields
Enter date and/or time values in datetime elds in the following form: [yyy]y-[m]m-[d]d [h]h:[m]m:[s]s.[ffff]f. For example, you would enter 6:35:42 a.m., December 7, 1991, as follows:
1991-12-7 06:35:42
Interval Fields
Enter values that represent a span of time in interval elds. Intervals can be made up of years and months, or of days, hours, minutes, seconds, and fractions of a second. You cannot, however, combine months and days in the same interval value. You would enter an interval of 12 hours and 30 minutes as follows:
12:30
You cannot move the cursor out of a eld that contains an invalid value. You must enter an acceptable value or press the Interrupt key to cancel the Add option. When you create a form, you can specify acceptable values for a particular eld. For example, you can specify that a number eld accept only numbers from 1 through 50, or that a character eld accept only one of ve particular words. If you enter data the form cannot accept, PERFORM displays this message on the status line:
This value is not among the valid possibilities
You also can create a special formatcalled a picturefor a eld. For example, social security numbers always have the same format, and you might specify that format in a picture for a social security number eld. When a picture format is used, you cannot enter data that does not conform to the picture for a eld. (For details, refer to Chapter 2, The FORMBUILD Transaction Form Generator, in the INFORMIX-SQL Reference.)
Entering Data
3-15
Special Functions
As you enter data or a query, you can access three special functions by using specic keys.
Function Help Key Used The CONTROL-W key displays a HELP screen that contains a short summary of special keys, control keys, and editing keys, as well as other information about PERFORM. The ESCAPE key runs the option you select. For example, 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. On most systems, the CONTROL-C key interrupts or cancels the option you are using. For example, if you select Add when you really want Query, press CONTROL-C, then select the Query option.
Execute
Interrupt
Forward
Fast Forward
Fast Backspace
Field Editing
If you make a mistake while entering data in a eld, you can correct it by backspacing and retyping. However, it is often faster to use the PERFORM eld-editing feature. You can use two editing modes to enter data in a eld:
In typeover mode, the characters you type replace existing data. You could
use typeover mode to change Sports R Us to Abes Sporting Goods.
In insert mode, the characters you type push existing data to the right. You
could use insert mode to add an i to Rchard. When you access PERFORM, you are in typeover mode; you must press CONTROL-A to change to insert mode. Press CONTROL-A a second time to return to typeover mode. Edit data that appears in a eld by using the following keys:
Function Backspace Key Used
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 eld, the cursor moves back to the previous eld. Forward The [ ] key moves the cursor forward one character at a time without erasing any text. If you press [ ] at the end of a eld, the cursor moves forward to the next eld. Delete a Character The CONTROL-X key deletes the character beneath the cursor. The cursor remains in place, and text shifts over to ll the space that was occupied by the deleted character. Change Mode The CONTROL-A key shifts between insert and typeover mode. When you access PERFORM, you are in typeover mode. Delete Forward The CONTROL-D key deletes everything from the current cursor position to the end of the eld you are editing. Repeat Data The CONTROL-P key enters the most recently displayed value in a eld. When you use the Add option to enter several rows in which one or more elds contain the same data, you can avoid retyping the data by pressing CONTROL-P. When you use the Update option, CONTROL-P restores the value that appeared in a eld before you modied it. Clear Screen The CONTROL-C key clears any search criteria you have entered with the Query option.
Entering Data
3-17
Removing a Row
Removing a Row
Use the Remove option to delete a row from the active table. For example, you would use Remove to delete information about a customer who quits the sporting goods business. Like Update, the Remove option affects only the row that currently appears on the screen. When the row you want to delete appears on the screen, you can delete it in the following way: 1. Type r to select the Remove option. PERFORM displays the REMOVE menu and, in the upper left corner of the screen, asks
REMOVE: Yes No Removes this row from the active table.
2. To remove the row, enter y. If you do not want to remove the row, enter n. 3. Enter y and PERFORM removes the row, clears the information from the screen, and displays the following message:
Row deleted
Exiting PERFORM
When you have nished working with a form, use the Exit option to leave PERFORM and return to the FORM menu. You can then choose to work with another form or return to the I-SQL Main menu. If you accessed PERFORM from the operating system command line, the Exit option returns you to the operating system.
Entering Data
3-19
Exiting PERFORM
Chapter
Querying a Database
Chapter Overview 3 What Is a Database Query? 3 Searching for an Exact Match 4 Searching for a Group of Rows 7 Finding All the Rows in a Table 9 How Database Queries Work 10 Searching with Relational Operators 11 Using Wildcard Characters 12 Searching for a Range of Values 13 Searching for the Highest and Lowest Values 14 Searching for Alternative Values 15 Query Operators and Short Fields 15 Searching in SMALLFLOAT and FLOAT Fields 16 Sample Database Queries 16 Moving from Screen to Screen Saving the Results of a Query 17 17
4-2
Querying a Database
Chapter Overview
This chapter explains how to use a screen form to retrieve data stored in an INFORMIX-SQL (I-SQL) database. The following topics are discussed:
Conducting database queries Using search criteria in a database query Searching for a single row Searching for a group of rows Retrieving all rows in a table Scanning through a group of rows Moving from page to page on a multiple-page form Saving the results of a query in a le
You should read this chapter if you want to learn how to use PERFORM to query a database. For additional information about querying a database with PERFORM, refer to Chapter 3, The PERFORM Screen Transaction Processor, in the INFORMIX-SQL Reference.
Querying a Database
4-3
The examples in this section are based on the customer form included with the demonstration database. The form, as it appears on the screen, is displayed as follows:
PERFORM: Query Next Previous View Add Update Remove Table . . . Searches the active database table. ** 1: customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [ ]
[ [ [ [ [
Last Name: ] ]
City : Telephone :
] ]
State :
Zip :
_______________________________________________________________________________ _______________________________________________________________________________
4-4
Querying a Database
You can use the customer form to search for an individual customers row. First, type q to select the Query option, and then type the companys name in the Company eld. For example, to search for the row containing information about the All Sports Supplies company, you would complete the form as shown:
QUERY: ESCAPE queries. INTERRUPT discards query. ARROW keys move cursor. Searches the active database table. ** 1. customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [ ]
Last Name:
City : Telephone :
State :
Zip :
_______________________________________________________________________________ _______________________________________________________________________________
The completed QUERY Screen tells PERFORM to search for rows in which the company column contains All Sports Supplies. Leaving the other elds blank tells PERFORM not to consider them as part of the query.
Querying a Database
4-5
To initiate the search, press the ESCAPE key. When PERFORM locates the row, it appears on the screen, along with a message on the Status line indicating the results of the search:
PERFORM: Query Next Previous View Add Update Remove Table . . . Searches the active database table. ** 1: customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [101 ]
Last Name:
[Pauli
City : Telephone :
State :
[CA]
Zip :
[94086]
_______________________________________________________________________________ _______________________________________________________________________________
1 row(s) found
4-6
Querying a Database
for all customers with stores in Redwood City, complete the customer form as follows:
PERFORM: Query Next Previous View Add Update Remove Table . . . Searches the active database table. ** 1: customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [ ]
[ [ [ [Redwood City [
] ] ] ] ]
Last Name:
City : Telephone :
State :
Zip :
_______________________________________________________________________________ _______________________________________________________________________________
Querying a Database
4-7
This screen instructs PERFORM to search for rows in which the city column contains Redwood City and to disregard the values contained in all other elds. When you press the ESCAPE key, PERFORM responds as follows:
PERFORM: Query Next Previous View Add Update Remove Table . . . Searches the active database table. ** 1: customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [104 Play Ball! [Anthony ]
Last Name:
[Higgins
[East Shopping Cntr. ] [422 Bay Road ] [Redwood City [415-368-1100 ] ] State : [CA] Zip : [94026]
City : Telephone :
_______________________________________________________________________________ _______________________________________________________________________________
5 row(s) found
The message on the Status line indicates that PERFORM found rows for ve customers with locations in Redwood City. However, only the rst row PERFORM found appears on the screen.
4-8
Querying a Database
If you want to skip more than one row at a time, type a number before you enter the option. For example, to skip forward three rows, type 3n.
[Pauli
City : Telephone :
Zip :
[94086]
_______________________________________________________________________________ _______________________________________________________________________________
18 row(s) found
Querying a Database
4-9
it nds that satisfy your search criteria into the current list, displaying the rst one on the screen. If you enter search criteria in more than one eld, PERFORM selects only rows that satisfy the criteria for all search elds. If you make an error while entering search criteria, you can use CONTROL-C to clear the criteria you entered. When you want only rows in which a eld contains a particular value, enter that value in the eld. You also can use these other methods:
Relational and range operators to search for values that lie within a particular range
Pattern =x >x <x >=x <=x <>x x:y x..y *x, x*, *x* ?x, x?, ?x?, x?? x|y
all
If you enter an equal sign by itself in a CHAR eld, PERFORM searches for
rows in which that eld contains NULL values.
have to use the equal sign with the asterisk because the asterisk is also a query operator.) Normally, you enter an operator followed by a value, with no spaces between them. The following guidelines explain how to use the relational operators in different types of elds. The examples are based on the customer form in the demonstration database.
Number Fields
Enter an operator and a number. For example, to search for all rows in which the customer number is greater than 110, enter >110 in the Customer Number eld.
INTERVAL Fields
Enter an operator and a value. Less than means a shorter span of time, while greater than means a longer span of time than you entered. For example, to nd orders that are older than 1 year and 6 months, enter >1-6.
Querying a Database 4-11
MONEY Fields
Operators are also useful when querying MONEY elds. For example, to nd rows with a value less than $12,000, enter <12000 in a MONEY eld. Do not enter a dollar sign or comma in your query. PERFORM adds the dollar sign automatically. A MONEY eld is also present in the form that is used in the next chapter.
CHAR Fields
When you use a relational operator in a CHAR eld, the following conditions exist:
Greater than means later in the alphabet, and less than means earlier in the
alphabet.
Lowercase letters are greater than uppercase letters. Both uppercase and lowercase letters are greater than numbers.
PERFORM compares characters based on ASCII values. (An ASCII collatingorder chart appears in the Relational Operator section in Chapter 6 of The Informix Guide to SQL: Reference.)
For example, to nd rows for customers whose last names are alphabetized after Baxter, enter >Baxter in the Last Name eld. Because lowercase letters have a higher ASCII value than uppercase letters, this search criterion also nds all names that begin with lowercase letters.
NLS
When NLS is active, the results of character comparisons are dependent on the NLS locale settings, and can differ from strict ASCII ordering. Refer to Appendix C, Native Language Support in INFORMIX-SQL, in the INFORMIX-SQL Reference.
in the Address eld, PERFORM nds 41 Jordan Avenue and 776 Gary Avenue. The search pattern also would nd a truncated address like 41 Jordan Ave. You can use the ? to match a single character. The following screen shows a query using the ? wildcard character. PERFORM retrieves rows in the customer table where the value in the fname column contains a four-letter word beginning with any character and ending with the character string ick (Dick, Rick, Nick, and so on).
QUERY: ESCAPE queries. INTERRUPT discards query. ARROW keys move cursor. Searches the active database table. ** 1: customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [ ]
[?ick [ [ [ [
Last Name: ] ]
City : Telephone :
] ]
State :
Zip :
Querying a Database
4-13
You can use the range operator with CHAR elds. Because PERFORM compares characters based on ASCII values, lowercase letters are processed after uppercase letters. For example, to nd customer names that are alphabetized after (and including) Baxterbut omitting names that begin with a lowercase letter you must enter Baxter:a in the Last Name eld.
NLS
When NLS is active, the evaluation of characters relative to character ranges is dependent on the NLS locale settings, and can differ from strict ASCII ordering. Refer to Appendix C, Native Language Support in INFORMIX-SQL, in the INFORMIX-SQL Reference. When an odd number of colons (greater than two) appear in a query expression, the middle one is assumed to be a query operator. If the query expression contains an even number of colons and is not a valid single DATETIME or INTERVAL value, I-SQL returns an error. Since DATETIME and INTERVAL constants might include colons, do not use the colon (:) to search for a range of values. Instead, use the .. search operator with DATETIME and INTERVAL data types to avoid ambiguity. The .. range operator functions the same way as the colon does for other data types.
[ [ [ [ [
] ] ] ] ]
Last Name:
City : Telephone :
State :
Zip :
_______________________________________________________________________________ _______________________________________________________________________________
In this query, PERFORM searches for rows where the value in the customer_num column equals either 110 or 118. The row(s) returned from this query are placed in the current list.
Querying a Database
4-15
For example, when you enter 94060:94080 in the Zip eld, you see the following screen:
QUERY: ESCAPE queries. INTERRUPT discards query. ARROW keys move cursor. Searches the active database table. ** 1: customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [ ]
[ [ [ [ [
Last Name: ] ]
City : Telephone :
] ]
State :
Zip :
[94060]
_______________________________________________________________________________ _______________________________________________________________________________
[94060:94080
101:110 in the Customer Number eld Redwood City in the City eld 94062 in the Zip eld
The Output option produces the current list only. Before you can select the Output option, you must rst use the Query, Next, or Previous option to locate the row or rows you want to output. For example, you can use the customer form to create a list of customers located in Palo Alto. Select the Query option, enter Palo Alto in the City eld, then press the ESCAPE key. The results of the query look like those on the next screen:
PERFORM: Query Next Previous View Add Update Remove Table . . . Searches the active database table. ** 1: customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [103 ]
Phils Sports [Philip [654 Poplar [P. O. Box 3498 [Palo Alto [415-328-4543
] ] ] ] ]
Last Name:
[Currie
City : Telephone :
State :
[CA]
Zip :
[94303]
_______________________________________________________________________________ _______________________________________________________________________________
2 row(s) found
Rows for the two Palo Alto businesses are now in the current list. You should always use the Query option before you select the Output option. Then type o to select the Output option. In the upper left corner of the screen, PERFORM displays the following dialog:
Enter output file (default is perform.out): Enter an output file name.
The default le is the le you used most recently with the Output option. If you have not used the Output option since accessing PERFORM, the default is perform.out. You can type the name of the le you want PERFORM to use and then press RETURN, or simply press RETURN to use the default le name. By default, the le appears in your current working directory. You can place the le in another directory by providing a full pathname.
4-18 Querying a Database
When you press the RETURN key, PERFORM displays the name of the le you selected and asks if you want to create a new le or append the output to an existing le. If you choose the default le name perform.out, you see the following menu:
FORM OUTPUT FILE: Append Create Adds new data to an existing output file.
If you select a le that already contains data, and you do not want to delete that data, type a to append the new data to the end of the existing le. To create a new le, type c. If you select an existing le and select the Create option, PERFORM deletes the old version of the le when you run the Output option, and you lose any data stored in that le. When you press the RETURN key, PERFORM displays this message:
FORM OUTPUT FILE LIST: Current-list One-page Writes the Current List to the file.
You can ask PERFORM to output data for all rows in the current list, or you can request a single row at a time. Type c or press RETURN if you want to output every row in the current list. Type o to output only the row that currently appears on your screen. To output some but not all of the rows in the current list, you can alternate between the Output and Next/Previous menu options. When you type c or o, PERFORM prompts you for the format of the output le:
OUTPUT FORMAT: Unload-format Screen-format Writes the selected output in ASCII format
Querying a Database
4-19
Press RETURN or type u to output the retrieved row or rows as an ASCII le in unload format. Select this option if you plan to use this le in an ACE report or as input for another application. Type s if you want to output the retrieved row or rows in a le formatted to look the same as your screen display. Like the screen display, the le includes the data and any additional eld labels, boxes, lines, or other screen items. The Screen-format option just produces a copy of the displayed page of the screen form. This output is ne if you use a single-page form. However, if you want to output data from several pages of a multiple-page form, you must alternate between the Output and Screen options. When you type s, PERFORM writes the rows to the le. A counter at the bottom of the screen increments as each output row is written to the le:
Output record number 1 PERFORM displays each row that it writes and updates the counter as it
does so.
This is what the perform.out le, which is based on your search for Palo Alto businesses, might look like when printed in the screen format:
_______________________________________________________________________ _______________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [103 ]
Phils Sports [Philip [654 Poplar [P. O. Box 3498 [Palo Alto [415-328-4543
] ] ] ] ]
Last Name:
[Currie
City : Telephone :
State :
[CA]
Zip :
[94303]
_______________________________________________________________________ _______________________________________________________________________
[107
[Ream
City : Telephone :
Zip :
[94304]
_______________________________________________________________________ _______________________________________________________________________
Querying a Database
4-21
This is what the perform.out le might look like when printed in the unload format:
_____________________________________________________________________________ _____________________________________________________________________________ 103|Phils Sports|Philip|Currie|654 Poplar|P. O. Box 3498|Palo Alto|CA|94303| 415-328-4543| 107|Athletic Supplies|Charles|Ream|41 Jordan Avenue||Palo Alto|CA|94304|415356-9876| _____________________________________________________________________________ _____________________________________________________________________________
Chapter
The Master-Detail Relationship 11 Selecting the Detail Table 11 Returning to the Master Table 13 Multiple Tables and Current Lists 14 Using the Current Option 14
5-2
Chapter Overview
This chapter describes the special features of PERFORM that are available when you work with forms that include data from more than one table. The discussion includes the following topics:
Multiple-table forms The active table Join elds Verify joins Lookup elds Master-detail relationships Multiple-screen forms
You should read this chapter if you will be using or creating screen forms that include data taken from more than one table.
Join elds let you use a single eld to represent data from columns in
different tables.
Once you join elds, you can create master-detail relationships that make it
possible to conduct cross-table queries with a single keystroke.
5-3
This chapter presents important background information on the PERFORM program and discusses the various techniques in detail.
determined when you create the form. When you access PERFORM, it selects the rst table as the active table. The table name and number appear on the second information line and its elds are enclosed in brackets (or the alternative eld delimiters you have selected).
The customer table contains one row for each customer. The orders table contains one row for each order placed by a customer. The items table contains one row for each item ordered in a customer
order.
The stock table contains one row for each item of stock in the stores
inventory.
The manufact table contains one row for each manufacturer who does
business with the store.
5-4 Using Multiple-Table Forms
The state table contains the names and postal abbreviations of the 50
states in the United States. The cust_calls table contains information about telephone calls that customers made to the business.
OL
When you use the INFORMIX-OnLine Dynamic Server, the stores demonstration database contains an additional table called catalog that contains information about items that are in stock. The orderform form includes data from four of these tables: customer, orders, items, and manufact. When you use the orderform form with PERFORM, you see the following screen:
PERFORM: Query Next Previous View Add Update Remove Table . . . Searches for the active database table. ** 1: customer table** -------------------------------------------------------------------------CUSTOMER INFORMATION: Customer Number: [ ] Telephone: [ ] Company: [ ] First Name: [ ] Last Name: [ ] Address: [ ] [ ] City: [ ] State: [ ] Zip: [ ] -------------------------------------------------------------------------ORDER INFORMATION: Order Number: Order Date: Stock Number: Manufacturer: Quantity: Total Price: SHIPPING INFORMATION: Customer P.O.: Ship Date: Date Paid:
5-5
If you use the Table option to select the next table, you see the following screen:
PERFORM: Query Next Previous View Add Update Remove Table . . . Selects the current table. ** 2: orders table** -------------------------------------------------------------------------CUSTOMER INFORMATION: Customer Number: [ ] Telephone: Company: First Name: Last Name: Address: City: State: Zip:
-------------------------------------------------------------------------ORDER INFORMATION: Order Number: [ ] Order Date: [ ] Stock Number: Manufacturer: Quantity: Total Price: SHIPPING INFORMATION: Customer P.O.: [ Ship Date: [ ] ] Date Paid: [ ]
The information line shows that orders is now the active table. Fields from the orders table (on the lower half of the screen) are enclosed in brackets. Note that the Customer Number eld remains in brackets when either the customer table or the orders table is the active table. The signicance is discussed in the Join Fields section that follows.
5-6
Join Fields
If you use the Table option to again select the next table, you see the following screen:
PERFORM: Query Next Previous View Add Update Remove Table . . . Selects the current table. ** 3: items table** -------------------------------------------------------------------------CUSTOMER INFORMATION: Customer Number: Telephone: Company: First Name: Last Name: Address: City: State: Zip:
-------------------------------------------------------------------------ORDER INFORMATION: Order Number: [ ] Order Date: Stock Number: [ ] Manufacturer: [ ] Quantity: [ Total Price: [$ SHIPPING INFORMATION: Customer P.O.: Ship Date: Date Paid: ] ]
The second information line shows that items is now the active table, and elds from the items table (on the lower half of the screen) are in brackets. The Order Number eld remains in brackets when either the orders table or the items table is the active table. Note: Although the manufact table contributes information to the screen form, it is never available as the active table. Thus, you cannot use it for querying, updating, or adding new information.
Join Fields
Use a multiple-table form whenever you want to have access to the data in more than one table at the same time. Normally, the tables have at least one column that contains the same kind of information. When you create a multiple-table form, you join columns from different tables that contain the same information. In PERFORM, joining means using a single eld to represent data taken from more than one table. The display eld is called a join eld, and the columns involved are called join columns.
5-7
Join Fields
A join eld represents data from more than one table and appears in brackets whenever any of the tables containing the data is active. Think of the join eld as a bridge that links the related information in two or more different tables. For example, the customer_num column in the customer table, and the customer_num column in the orders table, both contain customer numbers. Similarly, the order_num column in the orders table, and the order_num column in the items table, both contain order numbers. As illustrated in the previous section, the Customer Number eld is in brackets when either the customer table or the orders table is the active table. Similarly, the Order Number eld remains in brackets when either the orders table or the items table is the active table.
The Customer Number eld is a join eld. It links the customer_num eld from the customer table and the customer_num eld from the orders table. You can recognize it as a join eld because it is displayed in brackets when either customer or orders is the active table.
5-8
Join Fields
The bottom portion of the orderform form contains order information for customer 101. The join eld lets you simultaneously review information about this customer and information about an order placed by this customer. To verify the results shown on the screen, refer to Appendix A, The Demonstration Database and Application, in the INFORMIX-SQL Reference. That appendix contains tables of all the data in the demonstration database. To review the next customer row, use the Next option to advance to the next row in the current list.
PERFORM: Query Next Previous View Add Update Remove Table . . . Shows the next row in the Current List. ** 1: customer table** -------------------------------------------------------------------------CUSTOMER INFORMATION: Customer Number: [102 ] Telephone: [415-822-1289 ] Company: [Sports Spot ] First Name: [Carole ] Last Name: [Sadler ] Address: [785 Geary St ] [ ] City: [San Francisco ] State: [CA] Zip: [94117] -------------------------------------------------------------------------ORDER INFORMATION: Order Number: Order Date: Stock Number: Manufacturer: Quantity: Total Price: SHIPPING INFORMATION: Customer P.O.: Ship Date: Date Paid:
The Sports Spot company is customer 102. The join eld lets you see, at the bottom of the screen, information about orders placed by this customer. In this instance, the Sports Spot has yet to place an order, so elds in the bottom half of the screen are empty. Press the n key two more times. Notice how the information about the customer and that customers order(s) changes each time you press n.
5-9
Join Fields
When you reach customer number 104, your screen looks like this:
PERFORM: Query Next Previous View Add Update Remove Table . . . Shows the next row in the Current List. ** 1: customer table** -------------------------------------------------------------------------CUSTOMER INFORMATION: Customer Number: [104 ] Telephone: [415-368-1100 ] Company: [Play Ball! ] First Name: [Anthony ] Last Name: [Higgins ] Address: [East Shopping Cntr. ] [422 Bay Road ] City: [Redwood City ] State: [CA] Zip: [94026] -------------------------------------------------------------------------ORDER INFORMATION: Order Number: 1001 Order Date: 01/20/1986 Stock Number: 1 Manufacturer: HRO Hero Quantity: 1 Total Price: $250.00 SHIPPING INFORMATION: Customer P.O.: B77836 Ship Date: 02/01/1986 Date Paid: 03/22/1986
Verify Joins
It often is useful to verify that data exists in one table before PERFORM accepts it as input to another. For example, you do not want to enter a nonexistent customer number on the orderform form. A special type of join, called a verify join, ensures that you can enter only data that already exists in a database table. You set up verify joins when you create a screen form. If you enter invalid data in a verify join eld, PERFORM displays an error message. For example, if you enter an invalid customer number while orders is the active table, PERFORM displays the following:
This is an invalid value -- it does not exist in customer table
You can read about how to create verify joins in Chapter 6, Creating Your Own Forms.
Lookup Joins
Occasionally, you might want PERFORM to display data that is somehow related to the data you enter on the form. For example, for reference purposes, it might be useful for PERFORM to display a manufacturers full name when you enter the manufacturer code.
5-10 Using Multiple-Table Forms
You can use the lookup feature to nd and display data. The elds in which this data appears are called lookup elds; you can never enter data (or search criteria) in these elds. For example, the second line of the ORDER INFORMATION section of the orderform form shows the stock number and manufacturer code for each item ordered. The manufacturer code is part of the items table, but the manufacturer name is stored only in the manufact table. PERFORM looks it up when you enter the manufacturer code in the eld labeled Manufacturer. You can read about how to create lookup joins in the section entitled Joining Fields on page 6-28. Using the lookup feature to display information from a table does not make that table available for entering data or conducting queries. The orderform form shows information from the manufact table, but the information appears in a lookup eld. You cannot make manufact the active table; you cannot query it, and you cannot enter, delete, or update the data stored in it.
5-11
Type d to select the detail table and initiate the search. PERFORM displays the following message:
Searching ...
while conducting the search and then indicates the results of the query:
4 row(s) found
Just as it does with the Query option, PERFORM places the rows it nds into the current list, which you can scan by using the Next and Previous options. (If there is already a current list, the Detail query replaces it with the new results.) For example, the orderform screen form, with the customer table as the active table and customer number 104 as the current row, appears in the following screen:
PERFORM: Query Next Previous View Add Update Remove Table . . . Searches the active database table. ** 1: customer table** -------------------------------------------------------------------------CUSTOMER INFORMATION: Customer Number: [104 ] Telephone: [415-368-1100 ] Company: [Play Ball! ] First Name: [Anthony ] Last Name: [Higgins ] Address: [East Shopping Cntr. ] [422 Bay Road ] City: [Redwood City ] State: [CA] Zip: [94026] -------------------------------------------------------------------------ORDER INFORMATION: Order Number: 1001 Order Date: 01/20/1986 Stock Number: 1 Manufacturer: HRO Hero Quantity: 1 Total Price: $250.00 SHIPPING INFORMATION: Customer P.O.: B77836 Ship Date: 02/01/1986 Date Paid: 03/22/1986
The second information line indicates that customer is the active table, and the screen shows data about customer number 104. The customer table is the master table for the orders table. You can obtain information about the orders placed by customer 104 by using the Detail option. When you type d, PERFORM switches tables and queries the database, using the value in the Customer Number eld as its search criterion.
PERFORM selects the detail table, orders, and automatically initiates a query
and Previous options to scan these rows. If you use the Detail option when no detail table exists for the active table,
PERFORM displays this message: No detail table has been specified for this table
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.
screen form. You can query one table, switch tables, query the second table, then return to the rst table, and still use the Next and Previous options to review the results of the original query.
Chapter
Changing Default Field Values 23 Using Todays Date as the Default 24 Using the Current Time as the Default 24 Requiring User Input 25 Specifying Acceptable Values 25 The Lowest Value Must Appear First 26 Using INCLUDE with CHAR Fields 26 Verifying Input 27 Joining Fields 28 Verify Joins 30 Lookup Joins 30 The INSTRUCTIONS Section 32 Calling C Functions from PERFORM 32
6-2
Chapter Overview
Earlier chapters described how to enter data and query a database using existing screen forms. This chapter explains how to create your own forms. The following topics are discussed:
Creating a default form specication Using a default screen form Modifying a default form specication
You should read this chapter if you want to learn how to create and customize your own screen forms. For additional information about the features introduced in this chapter, refer to Chapter 2, The FORMBUILD Transaction Form Generator, in the INFORMIX-SQL Reference.
6-3
6-4
After you select a database, choose the Form option on the Main menu:
INFORMIX-SQL: Form Report Query-Language Run, Modify, Create, or Drop a form. User-menu Database Table Exit
New
Compile
Drop
Exit
GENERATE FORM >> Enter the name you want to assign to the form, then press Enter. ----------------------- stores2 ---------------- Press CONTROL-W for Help ---------
Type the name you want to assign to the form and press RETURN.
6-5
CHOOSE TABLE >> Choose the table to be used in the default form. ------------------------ stores2 --------------- Press CONTROL-W for Help --------customer items manufact orders state stock sysmenuitems sysmenus
Choose a table by typing or highlighting its name and pressing RETURN. I-SQL displays the GENERATE FORM menu:
GENERATE FORM: Table-selection-complete Select-more-tables Continue creating a default form with the selected tables. Exit
The Generate option lets you include data from up to eight different tables on a single form. To use more than one table in a screen form, choose the Selectmore-tables option. I-SQL displays the list of available tables and lets you select another table. When you have chosen all the tables you want to include in the form, select the Table-selection-complete option. I-SQL then creates the default form specication.
6-6
Note: If you want to include more than eight tables in a form, create the form from scratch using the New option on the FORM menu. See Chapter 2, The FORMBUILD Transaction Form Generator, in the INFORMIX-SQL Reference for more information. Use the Exit option to return to the FORM menu, if you decide you do not want to generate a default form.
You can now use the form. Later in this chapter, you will learn about the modications you can make to the default form specication le.
6-7
COMPILE FORM: Correct Exit Correct errors in the form specification. ----------------------- stores2 ------------- Press CONTROL-W for Help ------------
Choose the Correct option to correct the errors. I-SQL prompts you for the name of the system editor you want to use and displays the form specication le within the editor. (See Using the SQL Editor on page 7-9 for a discussion of how to use the system editor.) The le now contains error messages describing any errors you made. Note: The text of all error messages, along with suggestions for corrections, is included in the Informix Error Messages manual. Correct any errors and save the specication le. You do not need to delete the error messages themselves; FORMBUILD automatically removes them from the le. When you save the corrected form specication le, I-SQL redisplays the MODIFY FORM menu if you are modifying a form, or the NEW FORM menu if you are creating a form from scratch. You can then recompile the le and generate a usable screen form.
6-8
Note: If you create a default form specication from the operating system command line, you can specify a full pathname and have I-SQL store the two les in that directory. See Appendix H of the INFORMIX-SQL Reference for command-line syntax.
6-9
These sections appear in every default form specication. A form specication le that is not a default form specication also can contain an optional fth section called the INSTRUCTIONS section.
] ] ] ] ] ] ]
Figure 6-1
The form specication contains all the information PERFORM needs for the custom form. It includes DATABASE, SCREEN, TABLES, and ATTRIBUTES sections; it does not include an INSTRUCTIONS section. You can use the optional END keyword to mark the end of sections in the form specication le. Some users nd it helpful to indicate the close of a section with END. The forms included with the stores demonstration database include the END keyword.
6-11
The SCREEN section of the form specication le includes a field tag for
each eld on the form. These tags appear between the brackets that delimit the elds. Each eld must have a eld tag. FORMBUILD assigns eld tags automatically when you create a default form specication. In the custom specication le, the eld tags are f000, f001, f002, and so on. Except for eld tags and special graphics characters, PERFORM displays everything between the braces exactly as it appears in the specication. Refer to Chapter 2 in the INFORMIX-SQL Reference for information on how to use graphics characters in forms.
The TABLES section in a default form specication lists the table or tables that you chose when you created the specication. In the custom specication le, the following indicates that the custom form uses data from only the customer table:
tables customer
This statement means that PERFORM will display fname values in the f001 eld when you use the form to query the database. PERFORM will store any values you enter in the f001 eld in the fname column. Note: When you create a default form specication, FORMBUILD automatically assigns both table and column names to each eld. In most cases, the table name is optional. However, you must specify the table name when you refer to a column name that appears in more than one of the tables used in the form. You might prefer to adopt the table.column naming convention when you create all of your screen forms so that you can be sure that all of the column references are unambiguous.
6-13
The customer form in the stores demonstration database contains precisely the same information as the default custom form, but the two forms look and act differently. Here is how the customer screen form appears when used by PERFORM:
PERFORM: Query Next Previous View Add Update Remove Table . . . Searches the active database table. ** 1: customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [ ]
[ [ [ [ [
Last Name: ] ]
City : Telephone :
] ]
State :
Zip :
_______________________________________________________________________________ _______________________________________________________________________________
The customer form was created by modifying and recompiling the custom specication le.
City: Telephone:
_______________________________________________________________________________ _______________________________________________________________________________ } end tables customer attributes f000 f001 f002 f003 f004 f005 f006 a0 customer_num; company, reverse; fname, comments = "Please enter first name if available"; lname; address1; address2; city; 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 = = = = = = = =
Figure 6-2
6-15
database stores2 screen { customer_num [f000 fname [f001 lname [f002 company [f003 address1 [f004 address2 [f005 city [f006 state [a0] zipcode [f007 ] phone [f008 } end tables customer attributes f000 = customer.customer_num; f001 = customer.fname; f002 = customer.lname; f003 = customer.company; f004 = customer.address1; f005 = customer.address2; f006 = customer.city; a0 = customer.state; f007 = customer.zipcode; f008 = customer.phone; end
] ] ] ] ] ] ]
Figure 6-3
The following sections discuss the similarities and differences between the two form specications.
Fields on the custom form appear in a single column; the customer form
places them across the full width of the screen.
The custom form labels elds with the names of the columns to which
they correspond (customer_num, fname, and so on); the customer form uses labels like Name, Address, and Telephone.
The customer form also includes horizontal lines to make the screen more
attractive.
6-16 Creating Your Own Forms
These differences exist because of differences in the SCREEN sections of the two form specication les. You can use your system editor to make any changes you want to the appearance of a form. For instance, you can move elds, change the labels that appear alongside the elds, or add horizontal and vertical lines. You also can use special graphics characters in the SCREEN section to place boxes and rectangles on your screen form. The meaning of these graphics characters is terminal-dependent. Refer to Chapter 2 in the INFORMIX-SQL Reference for information on how to use graphics characters in forms. Be careful not to decrease the widths of the elds when you modify the SCREEN section, or they may no longer be wide enough to display the data in your database. The width of a display eld is the distance between the brackets that surround it.
6-17
assigns the eld f003 to the column company in the customer table. The customer screen form, however, includes specic attributes that dene the behavior of individual elds. For example, the customer specication assigns the REVERSE attribute to the f001 eld:
f001 = customer.company, reverse;
The REVERSE attribute causes PERFORM to display the eld in reverse video (dark letters on a light background). The next section explains how to use attributes like REVERSE to customize the way your forms look and behave.
column name
ATTRIBUTE LIST page 6-20
Only the field tag, equal sign, column name, and semicolon are required; an attribute list is optional.
To refer to the customer_num column in the orders table, enter the following:
orders.customer_num
Default form specications include the table name for every eld in the ATTRIBUTES section.
6-19
Enter COLOR, followed by an equal sign and the desired color or attribute. For example, if you were to assign color values to the customer specication le, the lines
f004=address1, color=yellow; f005=address2, color=yellow;
would cause PERFORM to display customer addresses in yellow type. You can display eld text in dark letters on a colored background by combining a color name and REVERSE. You also can use the optional WHERE keyword to
specify a condition under which the attribute takes effect. For example, you might want to combine attributes to call special attention to a particular customer as follows:
f009 = customer.customer_num, color = red reverse where f009 = 104;
See Chapter 2 of the INFORMIX-SQL Reference for more information about the COLOR attribute.
If you assign both the INVISIBLE and COLOR attributes to a eld, I-SQL ignores the COLOR attribute. However, if you specify COLOR=REVERSE, INFORMIX-SQL displays the eld in reverse video and makes the contents of that eld invisible. If you assign both the INVISIBLE and PICTURE attributes to a eld, I-SQL does not display the picture pattern. You can also see an INVISIBLE eld by using the Output option on the PERFORM menu. The Output option captures the information displayed on a screen. For information on displaying INVISIBLE elds using the PERFORM Output option, see Chapter 4, Querying a Database, in this manual, and the OUTPUT menu options section of Chapter 3 in the INFORMIX-SQL Reference.
6-21
Enter comments, followed by an equal sign, followed by the text of the comment enclosed in quotation marks. The entire text must t on one line. For example, in the customer specication le:
f002 = fname, comments = "Please enter first name if available";
causes PERFORM to display the comment appearing in quotation marks whenever the cursor moves into the Name eld, as shown in the following screen:
QUERY: ESCAPE queries. INTERRUPT discards query. ARROW keys move cursor. Searches the active database table. ** 1: customer table** _______________________________________________________________________________ _______________________________________________________________________________ CUSTOMERS Customer Number: Company : First Name: Address : [ ]
[ [ [ [ [
City : Telephone :
Zip :
_______________________________________________________________________________ _______________________________________________________________________________
causes PERFORM to convert two-letter state abbreviations to uppercase when you enter them into the State eld.
Uppercase and lowercase letters have different ASCII values; storing some kinds of CHAR data in one or the other format can simplify sorting data and querying a database. For example, without the UPSHIFT attribute, you might have to search for CA, ca, Ca, and cA to nd records for customers with locations in California. The UPSHIFT and DOWNSHIFT attributes are used only in CHAR elds. If you attempt to use them elsewhere, FORMBUILD ignores them.
When you use the Add option, PERFORM displays the screen form with the following characters in the indicated elds:
Type of Field Character Number Date Money Datetime Interval Default Display Blanks Blanks Blanks $ Blanks Blanks
You can avoid NULL values by including the WITHOUT NULL INPUT keywords in the DATABASE section of the form specication. When you add a new row to the database, PERFORM inserts blanks in CHAR and DATE elds without data, and zeros in number and MONEY elds without data. You can use the DEFAULT attribute to replace a elds NULL default value. For example, you might change the default for a phone number eld to show your local area code. Enter default, followed by an equal sign and the value you want to assign, as the default value for the eld. When you specify a DATE value, a DATETIME value in character-string format, or a CHAR value that contains punctuation, symbols, or blank spaces, you must enclose the value in quotation marks.
6-23
For example, if most customers are located in California, you might want to set a default for the State eld as follows:
a0=customer.state, upshift, default="CA";
The Order Date eld on the orderform form defaults to the current date. The TODAY attribute is used only in DATE elds. If you attempt to use it elsewhere, FORMBUILD generates an error message.
The CURRENT attribute is used only in DATETIME elds. If you attempt to use it elsewhere, FORMBUILD generates an error message.
This statement ensures that a telephone number appears in each row of the customer table. When you assign the REQUIRED attribute to a eld, PERFORM requires that you enter data in that eld before it accepts a new row for a table. If you try to save a new row without entering data in a required eld, PERFORM displays the following message:
This field requires an entered value
Note: The REQUIRED attribute works only with the Add option. You can remove data from required elds with the Update option.
6-25
You also can specify multiple ranges. For example, the attribute shown below species the ranges 1 to 50 and 60 to 100
include = (1 to 50, 60 to 100);
You can specify a CHAR range, too. PERFORM evaluates ranges based on the ASCII values for the low and high limits of the range. The following example prevents PERFORM from accepting values other than A1, A2, A3, A4, and A5:
field-tag = column, include (A1 to A5);
When you include a CHAR value that contains punctuation marks, symbols, or blank spaces, you must enclose the entire value in quotation marks:
field-tag = column, include = ("sporting goods", "goods, sporting");
Note: PERFORM displays an error message if you enter a value not specied with the INCLUDE attribute:
This value is not among the valid possibilities.
The message does not specify the acceptable values. You might consider using the COMMENTS attribute to display a message reminding users of the acceptable values.
Verifying Input
If a eld contains particularly critical data, you can use the VERIFY attribute to require users to enter the same value twice before PERFORM accepts it. That way, your database is less likely to contain incorrect data because of typographical errors. For example, if you were entering personnel information into a form, you might want to force the user to enter the employees salary twice before PERFORM accepts it. The specication le would include the following lines:
f006 = personnel.salary, verify;
When you enter a number in the Salary eld and press RETURN, PERFORM clears the eld and displays this message:
Please type again for verification
You must enter exactly the same data, character for character, a second time. (Remember that 49500 and 49500.00 are not exactly the same.) You can use many other attributes in addition to the ones discussed in this section. See Chapter 2 of the INFORMIX-SQL Reference for a complete list of PERFORM attributes.
6-27
Joining Fields
If you include data from more than one table on a form, you probably will want to include a join eld. To create a join eld, equate two database columns with the same eld tag in the ATTRIBUTES section. For example, the following line species that eld-tag is a join eld that joins the col1 and col2 columns:
field-tag = col1 = col2;
species that c1 is a join eld that joins the following columns: customer.customer_num and orders.customer_num. (The use of the asterisk in a join is described in the Verify Joins section that follows.) With a join eld, you can assign attributes that take effect only when one table is active, as well as attributes that are always in effect. If you want an attribute to apply at all times, enter it after the last column name. For example,
field-tag = col1 = col2, include = (1 to 100);
joins col1 to col2 in the tag eld and prevents PERFORM from accepting values less than 1 or greater than 100 for either col1 or col2. You also can specify an attribute that applies only when one le or the other is active. To do so, you must enter a separate attribute list for each column name. For example,
field-tag = col1, required, upshift; = col2, upshift;
again joins col1 and col2. When the col1 table is active, PERFORM requires that you enter a value and converts that value to uppercase letters. When the col2 table is active, you do not have to enter a value, although PERFORM will still convert any CHAR value you enter to uppercase letters. You can nd additional information about the placement of attributes in Chapter 2 of the INFORMIX-SQL Reference. The orderform form contains data from four of the tables in the stores demonstration database. Figure 6-4 shows the form specication for the orderform form:
6-28 Creating Your Own Forms
database stores2 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 ] Ship Date: [o21 } 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; i18 = quantity, include = (1 to 100); i19 = total_price; o20 = po_num; o21 = ship_date; o22 = paid_date; instructions customer master of orders; orders master of items; end ] Date Paid: [o22 ]
Figure 6-4
Verify Joins
Like the INCLUDE attribute, verify joins let you compare the value you enter in PERFORM with a list of acceptable values. With the INCLUDE attribute, you enter the acceptable values in the form specication. With a verify join, the acceptable values are stored in one of the tables in your database. To use a verify join, specify which column contains the acceptable values. PERFORM checks to see that the value you enter in a verify join eld already exists in the column you specify. To create a verify join, type an asterisk to the left of the name of the column in which the value should already exist. For example:
field-tag = col1 = *col2;
means that when the col1 table is active, PERFORM rejects any input to the eld that does not already exist in the col2 column. The orderform screen form in the stores demonstration database uses a verify join to prevent users from assigning orders to nonexistent customers:
c1 = *customer.customer_num = orders.customer_num;
When orders is the active table, PERFORM rejects any customer number you attempt to enter that does not already exist as a customer_num value in the customer table.
Lookup Joins
Lookup joins let you extract data from a table and display it on a form based on the value a user enters in one of the elds on the form. For example, the orderform form uses a lookup join to display the name of a manufacturer as soon as the user enters the manufacturer code. To use a lookup join, you must create one or more elds in the SCREEN section for the data you want to display. These lookup elds differ from other elds in that PERFORM never displays brackets around them, and thus users cannot modify the data that appears in them. You do not create a separate entry for the lookup elds in the ATTRIBUTES section. Instead, include the instructions for the lookup join in the attribute list for the eld on which you want PERFORM to base the lookup.
Here, eld-tag is the eld tag that appears in the SCREEN section for the
eld that PERFORM uses as the basis for the lookup. For example, in the orderform form, the manufacturer code is eld i16.
The col-name is the name of the column in which that data should be
stored; again, this is the manu_code column in the items table.
LOOKUP is a required keyword. The lookup-tag is the eld tag you used for the lookup eld in the SCREEN
section. In the example, manu_name is the lookup tag.
The equal sign is required. The lookup-col is the name of the column that contains the data you want
to look up. Normally, lookup-col is in a different table than col-name. In the example, the manu_name column in the manufact table is the lookup column.
JOINING is a required keyword. The join-col is the column that PERFORM joins to col-name to nd the data
you want to look up. The join-col is in the same table as the lookup-col. In the example, the manu_code column in the manufact table is the join column.
When you enter a manufacturer code in the i16 eld, PERFORM joins the manu_code column in the items table to the manu_code column in the manufact table. Based on the join, PERFORM extracts the manufacturer name from the manu_name column in the row of the manufact table that matches the manufacturer code you entered.
6-31
The asterisk placed before join-col means that this is a verify join. PERFORM prevents you from entering a manu_code into the items table that does not already exist in the manufact table.
Create master-detail relationships that simplify multiple-table queries. Perform arithmetic calculations based on the values entered in a eld and
display the results on a form or store them in a table.
Use different characters to delimit the elds on a form. Use composite joins to join tables based on the values contained in more
than one column.
modication. However, you might occasionally nd it necessary to add a feature that is not available. For example, a C function call from PERFORM might check on the validity of data, record the data and time and the name of the person updating the records, or update the database. For more information on calling C functions from PERFORM, see Chapter 6 in the INFORMIXSQL Reference. After you have written the le containing your C functions, you must compile the le and link the necessary library functions to create a custom version of sperform. For information on how to simplify these processes, see Creating and Compiling a Custom Form in Chapter 2 of the INFORMIXSQL Reference, or the FORM discussion in the INFORMIX-SQL Main Menu Options section of Chapter 1 in that manual.
Chapter
Using SQL
Chapter Overview 3 Examples Used in This Chapter What is SQL? 4 Using SQL Statements 4 Accessing SQL 5 SQL Options 5 The SQL SYNTAX Menu 6 Learning How to Use SQL 6 Differences between SQL and PERFORM How to Create a Table with SQL 8 Entering an SQL Statement 9 Using the SQL Editor 9 Using the Use-Editor Option 10 Running an SQL Statement 12 If There are Errors 12 Saving the Current Statements 13 Guidelines for Assigning Command Filenames 14 Using a Command File 14 15 16 7 3
7-2
Using SQL
Chapter Overview
This chapter explains how to use SQL with the data in a database. It covers the following topics:
Creating a table with SQL Using SQL as an interactive query language Granting database privileges to other users Using SQL to query a database and to store and sort query results Modifying the data in a table with SQL
You should read this chapter if you want a general overview on using SQL to create tables and to work with data in databases. For complete information on all the SQL statements, refer to the Informix Guide to SQL: Syntax, Version 6.0.
Using SQL
7-3
What is SQL?
What is SQL?
SQL is an English-like interactive query language that you can use when working with databases. The SQL provided with INFORMIX-SQL (I-SQL) is
Create and drop tables and indexes Enter and delete data Query a database Select a different current database Display information about one or more tables Rename tables and columns Check and repair tables Grant and revoke database and table privileges
This chapter explains how to create tables and indexes with SQL and how to grant database privileges. In addition, it describes how to use SQL to work with the data in a database in order to retrieve, manipulate, add, remove, and modify rows and columns. Chapter 9, Database Structure and Integrity, explains how to use the SQL menu system to modify the structure of databases and tables.
What is SQL?
Accessing SQL
Select the Query-language option on the I-SQL Main menu to access SQL. If you have not already selected a database to work with, I-SQL rst displays the CHOOSE DATABASE screen. Once you have selected a database, I-SQL displays the SQL menu:
SQL: New Run Modify Use-editor Output Enter new SQL statements using SQL editor. Choose Save Info Drop Exit
SQL Options
The SQL menu displays 10 options: New Enter new SQL statements. The statements you enter become the current statements, replacing any previous current statements. Run the current SQL statements. Modify the current SQL statements. Use a system editor to enter or modify the current SQL statements. Send the results of the current SQL statements to the screen or a le. You normally use this option only when you use SQL to query a database. Choose a le that contains SQL statements and make those statements the current statements. Save the current SQL statements in a le so you can use them again later. Display information about the current database. Drop an I-SQL command le. Return to the I-SQL Main menu.
Using SQL
7-5
What is SQL?
7-6
Using SQL
The statement tells I-SQL to select the data stored in the order_num, customer_num, order_date, and paid_date columns for every row in the orders table where the value in the order_date column is greater than 6/5/91. I-SQL sorts the rows by the value in the paid_date column and displays this output on the screen. (The {ex1} characters are a comment, indicating that the statement is an example that is included in the demonstration database. I-SQL ignores comments.) Once you enter the statement, you can run it and look at the results. The query results look like this:
order_num customer_num order_date paid_date 1006 1015 1013 1003 1008 1005 112 110 104 104 110 116 09/19/1990 07/10/1990 09/01/1990 10/12/1990 11/17/1990 12/04/1990
6 row(s) retrieved I-SQL displays only the information you request. It does not display a
complete row, for example, unless you ask for a complete row. If you want only the last names of customers with orders totaling more than $500, that is exactly what you getno rst names, no customer numbers, no address information.
Using SQL
7-7
With this exibility, you can specify which tables you want to query, join columns from different tables, perform mathematical and logical operations on data, and sort query resultsall at the time that you enter the SQL query.
This statement tells I-SQL to create a table named orders and species names and data types for 10 columns. Column names appear on the left, while data types are indicated on the right.
7-8
Using SQL
statement creates a table in the current database. Before you create a table, be sure that the current database is the one in which you want the new table to appear. When you are ready to enter the CREATE TABLE statement, select the New option on the SQL menu. The NEW Screen indicates you are using the SQL editor.
NEW: ESCAPE = Done editing Delete = Delete character Insert = Typeover/Insert F9 = Delete rest of line
Using SQL
7-9
The DELETE key deletes the character that appears beneath the cursor. The F9 key deletes characters from the current cursor position to the end of the line.
When you use the SQL editor, you can enter as many lines of text as you wish. You are limited only by the memory constraints of your system, not by the size of the screen. The SQL editor does not display more than 80 characters on a line. If you insert characters so the line exceeds 80 characters, I-SQL displays the percent sign (%) at the end of the line to indicate that you have entered characters beyond the eightieth column. Although I-SQL will read and compile these characters, it will be difcult for you to work with text that is not visible. It is a good idea to insert a RETURN somewhere in the rst 80 characters of each line so that the full text will appear on the screen. If you insert lines so that the total number of lines is greater than the screen can hold, the SQL editor scrolls down the page with the extra lines and displays the beginning and ending line numbers of the current page on the fourth line down from the top of the screen.
NEW: ESCAPE = Done editing Delete = Delete character Insert = Typeover/Insert F9 = Delete rest of line
If you prefer working with the system editor, you can always press ESCAPE and then select the Use-editor option on the SQL menu.
If this is the rst time in this session that you have used the Use-editor option, I-SQL may display the USE-EDITOR screen:
USE-EDITOR >>edlin Enter editor name. (RETURN only for default editor) ----------------------- stores2 -------------- Press CONTROL-W for Help --------
On this screen, vi is the default editor. (You may have a different default editor on your system.) You can specify your choice of editor with the DBEDIT environment variable. See Appendix B, Environment Variables, in the INFORMIX-SQL Reference, for instructions.) If you have already specied an editor with this screen or if you have specied an editor with DBEDIT, I-SQL calls up the editor immediately and does not display the USE-EDITOR screen. When the USE-EDITOR Screen appears, type the name of the editor you want to use, or press RETURN to select the default editor. I-SQL calls the editor you specied. Edit the text and then save the le, following the usual rules for the editor you select. The SQL menu is redisplayed.
Using SQL
7-11
----------------------- stores2 -------------- Press CONTROL-W for Help -------create table mytable (col1 decimal(6,2), col2 smallint, col3 integer, col4 smallfloat, col5 float, col6 serial(101), mydate date, mymoney money(8,2) )
To run the statement and create the table, select Run on the SQL menu. The Run option is already highlighted, so just press RETURN.
If you make any errors in a statement, I-SQL does not process the statement. Instead, it displays the statements you entered, along with a message describing the error. For example, if there is a mistake (perhaps a misspelled keyword), I-SQL displays an error message on the bottom of the screen and highlights the Modify option on the SQL menu.
SQL: New Run Modify Use-editor Output Choose Save Modify the current SQL statements using the SQL editor. Info Drop Exit
----------------------- stores2 -------------- Press CONTROL-W for Help -------create table mytable (col1 decimal(6,2), col2 smallint, col3 integer, col4 smallfloat, col5 float, col6 serial(101), mydate date, mymoney money(8,2)
When you press RETURN to select Modify, I-SQL calls the SQL editor and positions the cursor on the rst error. You can correct the mistake using the SQL editor (press ESCAPE when you have nished editing the statement), or you can select the Use-editor option and edit the statement using your system editor. Once you return to the SQL menu, you can run the statement again. Note: The text of all error messages, along with suggestions for corrections, is included in Informix Error Messages, Version 6.0.
Using SQL
7-13
To save the current statements in a command le, select the Save option on the SQL menu. I-SQL displays the SAVE screen and prompts you to enter a name for the command le.
SAVE >> Enter the name you want to assign to the command file. ----------------------- stores2 ------------- Press CONTROL-W for Help -------create table mytable (col1 decimal(6,2), col2 smallint, col3 integer, col4 smallfloat, col5 float, col6 serial(101), mydate date, mymoney money(8,2) )
following screen, you may see other command les that have been added to provide further practice once you are familiar with the demonstration database.
CHOOSE >> Choose a command file with the Arrow Keys, or enter a name, then press Enter. ----------------------- stores2 -------------- Press CONTROL-W for Help -------c_custom c_index c_items c_manuf c_orders c_orders c_stock c_stores ex1 ex10 ex11 ex12 ex13 ex14 ex15 ex16 ex17 ex18 ex19 ex20 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10
To select a command le, use the Arrow keys to move the highlight over its name, then press RETURN. You also can type the name of the le you want and press RETURN. After you select a command le, the SQL menu appears. The statements contained in the command le are now the current statements, and they appear on the screen. You can modify or run these statements.
Using SQL
7-15
The sample statements in this chapter are formatted so you can read them easily. You can include comments in your SQL statements; just enclose your comments in braces ( { } ) like this:
select customer_num, lname, city, phone from customer {beginning of statement} {list of columns}
You also can indicate comments by preceding the comment with a pound sign ( # ) or double dashes ( -- ). Comments are for your use only; I-SQL does not process comments. You can include several SQL statements at one time, but you must separate them with semicolons, as in the following example:
select order_num from orders; select customer_num, lname, city, phone from customer {ex5}
Semicolons are statement separators, not terminators. You do not have to type a semicolon at the end of your last statement. I-SQL sequentially processes your statements and displays the output.
If you want to send your query results directly to the printer, select the Printer option on the OUTPUT menu. I-SQL sends the query results directly to your printer and displays a message on the bottom of the screen telling how many rows it retrieved. The query results do not appear on the screen.
I-SQL lets you write query results to a new le or append the results to an
existing le. You can use your operating system programs to edit, copy, rename, or delete the le.
There are six options on the Info menu: Columns Indexes Lists all the columns in the table and the data type of each column. Lists the indexes for the table, the owner and type of each index, whether it is a cluster index, and the columns to which each index applies.
Using SQL 7-17
Privileges
Lists the users who have access privileges for the table and whether they have the table-level privileges Select, Update, Insert, Delete, Index, and Alter. (Unless your login is listed separately, you have the privileges given for public, which is a general category for all users.) Lists the table name, the table owner, the size of the row (in number of characters), the number of rows in the table (as of the last UPDATE STATISTICS statement), the number of columns in a row, the date the table was created, and the name of the audit trail le (if there is one). Lets you select a new table for examination. Returns to the SQL menu.
Status
Table Exit
The Info option is also available from the TABLE menu. You can use this option to gather information about external tables. For information on how to use the Info option with OnLine, see Appendix I in the INFORMIX-SQL Reference.
Chapter
Compiling a Report Specication 18 If the Compilation Is Unsuccessful What a Report Specication Contains Listing the Instructions 20 Including Comments 21
Selecting the Data for a Report 22 Formatting the Report 22 Selecting All Rows and Columns in a Table 23 Selecting Data from More than One Table 23
24
Basic Report Formatting 25 The OUTPUT Section 25 The FORMAT Section 26 FORMAT for a Default Report 26 FORMAT for a Custom Report 27 Creating Page Headers and Trailers 27 Where Headers and Trailers Appear 27 Printing a Report Heading 28 Printing Column Headings 29 Numbering Pages Automatically 30 Printing Rows of Data 30 Grouping Data 33 Using Calculations in a Report 36 Arithmetic Operators 36 Example of Arithmetic Operations 36 Using Parentheses 37 Controlling the Appearance of Numbers 37 Using Fill Characters 38 The Fill Characters 39 Adding a Dollar Sign 39 Making the Dollar Sign Float 40 Math Functions 40 Totaling a Column 41 Counting Rows in a Report 43 Combining Arithmetic Operators and Math Functions Group Functions 45 Displaying a Report 47 Printing the Report on a Printer 48 Piping the Report to Another Program Calling C Functions from ACE 49
45
49
8-2
Chapter Overview
This chapter explains how to create, display, and print reports with INFORMIX-SQL (I-SQL). The following topics are discussed:
Using a report writer Creating and compiling a report specication Including selected database information in a report Including data from an input le in a report Grouping and formatting the information Adding titles, headings, and other text to customize the report Displaying the report on your terminal or sending it to the printer
Read this chapter if you want to learn how to create your own I-SQL reports. If you intend to use only reports that someone else creates, you do not need to read this entire chapter. Instead, go to the section entitled Running the Report on page 8-14. For complete information about all the features available for creating and running reports, see Chapter 4, The ACE Report Writer, in the INFORMIXSQL Reference.
8-3
The ACE report writer retrieves data from a database or from a le, organizes and formats it according to your instructions, adds the headings or column titles you specify, performs calculations on number columns, and then displays the report. You can combine information from several tables in a database to create whatever kind of report you need. Some of the kinds of reports ACE can produce are as follows:
Mailing labels Form letters Payroll summaries Medical histories Accounting records Inventory lists Telephone directories Project schedules Sales and marketing reports Payroll checks
Example report specications are included in the section A Sample Specication and Report on page 8-6. They should serve as useful models for creating similar reports for your databases.
Figure 8-1 shows an overview of the steps involved in creating and displaying a report:
Step 1. Step 2. Step 3. Step 4. Figure 8-1 Create a report specication. Compile the specication. If there are errors, correct the errors, and then go back to Step 2. When there are no more compilation errors, run the report.
The REPORT menu displays the following seven options: Run Modify Displays a report. Changes an existing report specication.
Generate Generates a default report specication based on a database table. New Compile Drop Exit Creates a new report specication. Compiles a report specication. Drops a report. Returns to the I-SQL Main menu.
8-5
CUSTOMER LIST September 30, 1994 Last Name Vector Lawson Company Los Altos Sports Runners & Others City Los Altos Los Altos
Beatty Grant
Watson Parmelee
Baxter
Oakland
Currie Ream
Sadler
Sports Spot
San Francisco
All Sports Supplies Sunnyvale Sport Stuff Sunnyvale Sports Center Sunnyvale
18
Confidential Information
Page
A sample report
This report lists the last name, company, and city for all customers. It groups customers by city and calculates the total number of customers. A notation that this is condential information and the current page number are printed at the bottom of each page. Figure 8-3 shows the report specication used to generate the sample report:
database stores2 end select lname, company, city from customer order by city end format page header print column 20, "CUSTOMER LIST" skip 1 line print column 18, "September 30, 1994" skip 2 lines print "Last Name", column 18, "Company", column 40, "City" skip 2 lines on every row print lname, column 18, company, column 40, city after group of city skip 2 lines on last row skip 2 lines print column 12, "Total Number of Customers:", column 40, count using "##" page trailer print "Confidential Information", column 55, pageno using "Page ##" end Figure 8-3 A sample report specication
8-7
In this sample specication, the information for the report is contained in the stores demonstration database.
8-8
Selects the information in the last name, company, and city columns. Indicates that the columns are contained in the customer table. Orders the rows (in ascending order) by city.
In earlier releases, you were limited to using the ORDER BY clause in only the last SELECT statement. With this release, you can include the ORDER BY clause in any SELECT statement. For a complete explanation of the SELECT statement, refer to Chapter 6, Syntax, in the Informix Guide to SQL: Reference, Version 4.1.
8-9
In this example, the FORMAT section contains a list of instructions in the following ve control blocks:
PAGE HEADER
Prints a report title (CUSTOMER LIST), skips one line, and prints a date (September 30, 1994); skips two lines and prints column headings (Last Name, Company, and City) in the designated column positions; skips two lines. Prints the contents of the last name, company, and city columns of every row in the designated column positions. clustered by city.
ON EVERY ROW
AFTER GROUP OF Skips two lines after printing each group of rows 8-10 Creating and Printing Reports
ON LAST ROW
After selecting the last row, skips two lines and prints a phrase (Total Number of Customers:) in the designated column position; calculates and displays the total number of customers. At the bottom of each page, prints the words Condential Information and the current page number.
PAGE TRAILER
Later in this chapter, you will learn how to format control blocks.
You can select the Generate option and generate a default report
specication.
Or, you can select the New option and use your system text editor to
create a new report specication. The next few pages describe the process of generating a default report specication. The use of the New option is covered in the REPORT section of The INFORMIX-SQL Main Menu Options discussion in Chapter 1 of the INFORMIX-SQL Reference.
8-11
After you select the Generate option (and choose a database), I-SQL prompts you to enter the name you want to assign to the new report specication.
The name can be up to 10 characters long. The report specication name must begin with a letter and can consist of
any combination of letters, numbers, and underscores (_). You can use uppercase and lowercase letters.
After you enter the name of the report specication, I-SQL displays the CHOOSE TABLE Screen. The following example lists some of the available tables:
CHOOSE TABLE >> Choose the table to be used in the default report. ----------------------- stores2 -------------- Press CONTROL-W for Help -------customer items manufact orders stock state
Choose the table that I-SQL will use for the default report. The default report will display information drawn from this table. Select a table from those listed on the screen (select customer to work with the customer table that is included in the stores demonstration database).
I-SQL displays the RUN REPORT screen that lists available reports.
For example:
RUN REPORT >> Choose a report with Arrow Keys, or enter a name, then press Enter. ----------------------- stores2 -------------- Press CONTROL-W for Help -------clist1 clist2 mail1 mail2 mail3 ord1 ord2 ord3
(Reports in addition to the ones listed in this example are provided for further practice.) Type or highlight the name of the report you want to run and press RETURN. I-SQL runs the selected report.
Depending on the instructions that the report specication contains, the nished report is either displayed on your screen, written to a le, or printed on a printer. By default, I-SQL displays the results on the screen. Subsequent sections of this chapter describe how to store a report in a le or print it on the system printer. The following example shows the rst few lines of the default report based on the customer table:
customer_num fname lname company address1 address2 city state zipcode phone customer_num fname lname company address1 address2 city state zipcode phone customer_num fname lname company address1 address2 city state zipcode phone 101 Ludwig Pauli All Sports Supplies 213 Erstwild Court Sunnyvale CA 94086 408-789-8075 102 Carole Sadler Sports Spot 785 Geary St San Francisco CA 94117 415-822-1289 103 Philip Currie Phils Sports 654 Poplar P. O. Box 3498 Palo Alto CA 94303 415-328-4543
8-15
Modifying a Report
Modifying a Report
If you decide to make changes to an existing report, you must modify the report specication and then recompile it. To change a report specication, select the Modify option on the REPORT menu:
REPORT: Run Modify Generate Modify a report specification. New Compile Drop Exit
I-SQL displays the MODIFY REPORT screen with a list of available report specications (reports in addition to those listed here are provided for further practice):
MODIFY REPORT >> Choose a report with Arrow Keys, or enter a name, then press Enter. ----------------------- stores2 -------------- Press CONTROL-W for Help -------clist1 clist2 mail1 mail2 mail3 ord1 ord2 ord3
Type or highlight the name of the report specication you want to modify and press RETURN.
Modifying a Report
After you select the specication, I-SQL prompts you for the name of your editor (unless you have specied an editor previously in this session or set the DBEDIT environment variable as described in Appendix B, Environment Variables, in the INFORMIX-SQL Reference). I-SQL then activates your system text editor and displays the report specication le. You can make any changes you like to the specication, using your system editor. When you have nished entering changes to the specication, save the le according to the procedures you normally follow to save les with your text editor.
There are three options on the MODIFY REPORT menu: Compile Compiles the report specication and returns to the MODIFY REPORT menu if the compilation is successful. Once the report specication is compiled, you can save it and run it. Saves the report specication without compiling it and returns to the REPORT menu. You can edit and/or compile the report specication le at a later time. Discards the modications just made to the report specication le and returns to the REPORT menu.
Save-and-exit
Discard-and-exit
You probably will want to compile the report specication immediately. To do so, select the Compile option.
8-17
After attempting to compile a report specication that contains an error, I-SQL displays a message to that effect and displays the COMPILE REPORT menu:
COMPILE REPORT: Correct Exit Correct errors in the report specification. ----------------------- stores2 -------------- Press CONTROL-W for Help --------
To correct an error in the specication, select the Correct option on the COMPILE REPORT menu. I-SQL calls your system editor and displays the report specication on your screen, with errors agged by a caret (^), and an error message. Note: The text of all error messages, along with suggestions for corrections, is included in Informix Error Messages, Version 6.0. Figure 8-5 shows how the specication le might look after you attempted to compile it:
database stores2 {end keyword is missing} select #^ # # A grammatical error has been found on line 4, character 1. # The construct is not understandable in its context. # See error number -8018. # lname, company, city Figure 8-5 A report specication with an error marked
In this example, you need to correct the report specication by adding the keyword END to the DATABASE section. Note: In the example, ACE agged the word select as the point at which it encountered the error. In fact, it is the missing END keyword that caused the error. This demonstrates a common occurrence with ACE: an error often is located in the
8-19
control block immediately preceding the ag. When a grammatical error is agged, look at the block preceding the error ag and check for a missing or misspelled keyword, or a missing or misplaced punctuation mark. After you correct the error, save the specication le in the usual way and exit from your text editor. I-SQL removes the error message from the specication le when you save it. Choose the Compile option again to recompile the specication. When the report compiles successfully, I-SQL displays the MODIFY REPORT menu. Choose the Save-and-exit option. I-SQL saves the compiled report specication and displays the REPORT menu.
DATABASE (required) DEFINE INPUT OUTPUT SELECT (SELECT or READ required) READ (READ or SELECT required) FORMAT (required)
The control blocks contain statements, and most of the statements can contain clauses. For a complete description of an ACE report specication, refer to Chapter 4, The ACE Report Writer, in the INFORMIX-SQL Reference.
Including Comments
You can include comments in your report specication. That way, if you need to modify the report or if someone else reads the specication, comments explain what the specication does. Include comments within a set of braces ( { } ) or use a double dash ( -- ) prex. I-SQL ignores text enclosed in braces or preceded by a double dash. The following example report specication includes comments:
{ This report lists customers by company and city and groups by city } database {select stores2 database} stores2 end output left margin 10 end select lname, company, city from customer order by city end format page header {set up page headings} print column 20, "CUSTOMER LIST" skip 1 line print column 18, "September 30, 1994" skip 2 lines print "Last Name", column 18, "Company", column 40, "City" skip 2 lines on every row print lname, column 18, company, column 40, city after group of city skip 2 lines {format every row of output} {set left margin to 10}
{order by city}
on last row {count number of rows} skip 2 lines print column 12, "Total Number of Customers:", column 40, count using "##" page trailer {at bottom of page} print "Confidential Information", column 55, pageno using "Page ##" end
Figure 8-6
SELECT clause (required) FROM clause (required) WHERE clause GROUP BY clause HAVING clause ORDER BY clause INTO TEMP clause
Refer to the discussion of the SELECT statement in Chapter 6 of Informix Guide to SQL: Reference, Version 4.1, for more information about the syntax and usage of the SELECT statement.
To print only the last names and store names, specify the FORMAT section as follows:
format on every row print {printing data} lname, company end
8-23
By joining the two tables (on the manu_code column), you can include in your report information from the columns in both tables. This example selects stock numbers, manufacturer codes, stock descriptions, units, and unit prices from the stock table, and manufacturer names from the manufact table.
The following READ statement species an ASCII le corresponding to the stock table in the stores demonstration database:
read "stock1" delimiter ":" order by unit_price end
Note that the statement contains an ORDER BY clause, which is used to sort the records according to the values in the unit_price eld. The default sort order is ascending, that is, from the lowest to the highest price. The specied delimiter is a colon ( : ); the default delimiter is a vertical bar ( | ).
The READ statement requires an ASCII statement in the DEFINE section of the report specication. The ASCII statement assigns an identier and data type to each value that the READ statement references in the le. The following ASCII statement assigns identiers and data types to the values in the stock1 ASCII le. Each eld in stock1 has a corresponding eld in the stock table.
ASCII stocknum smallint, manucode char(3), unitdesc char(15), price money, unit char(4), unitname char(15)
Refer to Chapter 4, The ACE Report Writer, in the INFORMIX-SQL Reference for more information regarding the READ section and the READ statement.
Create page headers, page trailers, and column headings Print rows of information in the body of the report Group information Perform calculations, such as totals and averages Set up page margins and dimensions Specify whether you want the report to go to the screen or a le
8-25
LEFT MARGIN, 5 spaces TOP MARGIN, 3 lines BOTTOM MARGIN, 3 lines PAGE LENGTH, 66 lines (11 inches) Display the report on the screen TOP OF PAGE will ll the remaining lines of the current page with line
feeds when a new page is set up If you include an OUTPUT section, you must place it immediately before the SELECT or READ section in your report specication.
Following is a sample FORMAT section for an I-SQL report specication that uses an EVERY ROW statement:
format {format for a default report} every row end
FIRST PAGE HEADER PAGE HEADER PAGE TRAILER ON EVERY ROW ON LAST ROW BEFORE GROUP OF AFTER GROUP OF
For more information on these control blocks, see the Control Blocks section in Chapter 4 of the INFORMIX-SQL Reference.
8-27
Figure 8-7 shows the PAGE HEADER control block that produces this heading.
page header print column 20, "CUSTOMER LIST" skip 1 line print column 18, "September 30, 1994" Figure 8-7 A sample PAGE HEADER control block
This is what each keyword in the sample PAGE HEADER control block does:
PRINT
Use the PRINT statement to specify the text you want to print and the spacing you want to use. Enclose the text you want to print in quotation marks. If you want to control spacing, enter the number of spaces you want and the keyword SPACES. For example, to indent text 20 spaces, enter print 20 spaces. You also can position text with the COLUMN keyword.
COLUMN
Use the COLUMN keyword to place text in specic column positions. You also can position text with the SPACES keyword. Note: The COLUMN keyword operates with respect to the left margin. If the left margin is 5 spaces and you specify print column 15, printing actually will begin in column 20.
SKIP
Use the SKIP statement to specify how many blank lines you want to leave. If you want to advance to the top of the next page, use SKIP TO TOP OF PAGE.
Last Name
Company
City
To print the title and the column headings, use a PAGE HEADER control block like the one shown in Figure 8-8:
page header print column 20, "CUSTOMER LIST" skip 1 line print column 18, "September 30, 1994" skip 2 lines print "Last Name", {do not forget} column 18, "Company", {the commas} column 40, "City" skip 2 lines Figure 8-8 Column headings in a PAGE HEADER control block
Note: You must use commas to separate column keywords and the data that are to appear on the same line.
8-29
(Additional information about the keyword USING appears in the section Controlling the Appearance of Numbers on page 8-37 in this chapter.) This control block produces the following page trailer:
Confidential Information
Page
Figure 8-9 shows a report specication that uses an ON EVERY ROW control block. The ON EVERY ROW control block lists the same column names as the SELECT statement.
database stores2 end output left margin 10 end select lname, company, city from customer order by city end format page header print column 20, "CUSTOMER LIST" skip 1 line print column 18, "September 30, 1994" skip 2 lines print "Last Name", column 18, "Company", column 40, "City" skip 2 lines on every row print lname, column 18, company, column 40, city page trailer print "Confidential Information", column 55, pageno using "Page ##" end
Figure 8-9
This specication produces a report that prints the last name, rst name, and company for every customer.
8-31
CUSTOMER LIST September 30, 1994 Last Name Vector Lawson Beatty Grant Company Los Altos Sports Runners & Others Sportstown Gold Medal Sports City Los Altos Los Altos Menlo Park Menlo Park
Confidential Information
Page
Grouping Data
You can divide the information in a report into groups. For example, you might want to group customers by city, as illustrated in Figure 8-10:
Last Name
Company
City
Vector Lawson
Beatty Grant
Watson Parmelee
Baxter
Oakland
Currie Ream
Sadler
Sports Spot
San Francisco
Confidential Information
Page 01
Figure 8-10
8-33
The BEFORE GROUP OF and AFTER GROUP OF control blocks specify what I-SQL does when it gets to the beginning or end of a group. To use the group control blocks, enter the name of the column or identier that contains the information by which you want to group. The same column name or identier also must appear in the ORDER BY clause in the SELECT section or the READ section. The instructions you include in a BEFORE GROUP OF control block apply to actions I-SQL performs before printing the next group of rows. For example. you can use a BEFORE GROUP OF control block to print headings above a group of rows. The instructions you include in the AFTER GROUP OF control block apply to actions I-SQL performs after printing a group of rows. For example. you can use an AFTER GROUP OF control block to calculate totals or subtotals at the bottom of a group of rows. For example, if you want to group the information in a report by city, you rst must order by city in the SELECT or READ section. Then, you group by city in a BEFORE GROUP OF or AFTER GROUP OF control block in the FORMAT section.
Figure 8-11 shows a report specication that groups information by city. As shown in that gure, you must use the same column (city) to order and to group the information.
database stores2 end output left margin 10 end select lname, company, city from customer order by city {order by city} end format page header print column 20, "CUSTOMER LIST" skip 1 line print column 18, "September 30, 1994" skip 2 lines print "Last Name", column 18, "Company", column 40, "City" skip 2 lines on every row print lname, column 18, company, column 40, city after group of city skip 2 lines {group by city}
page trailer print "Confidential Information", column 55, pageno using "Page ##" end Figure 8-11 Grouping information with an AFTER GROUP OF clause
The specication in Figure 8-11 produces the CUSTOMER LIST report shown in Figure 8-10. The report groups together all the customers located in the same city.
Creating and Printing Reports 8-35
Arithmetic Operators
You can perform addition, subtraction, multiplication, division, or exponentiation on any of the number columns in a report. Use any of the following arithmetic operators in the FORMAT section:
Symbol + * / ** Function Addition Subtraction Multiplication Division Exponentiation
When you run the report, I-SQL multiplies the current unit price (unit_price) by 1.15 and prints the results in the report.
1 1 1 2 3 4
Using Parentheses
You can use parentheses in calculations to control the order in which I-SQL computes results. For example, if you want to divide the values in a column by 15 percent of 75, then add 100 to the result, specify the following:
print unit_price / (.15 * 75) + 100 using "$$$$$.$$"
you can format numbers to include dollar signs and commas, as follows:
$5,970 $8,520 $5,550
Note: If the columns in a table are the MONEY data type, I-SQL automatically formats the numbers with dollar signs.
8-37
The symbols between the quotation marks in the following PRINT USING statement are the pattern that I-SQL uses to format numbers in the unit_price column:
print unit_price * 1.15 using "####"
If a number is larger than the pattern you set up in the PRINT USING statement, I-SQL prints a group of asterisks instead of the number. Thus, if the numbers are 45, 456, 4560, and 45600, they appear in the report as follows:
45 456 4560 ****
* <
You can combine these symbols in a variety of ways to control and print numbers in the format you want. See the discussion of the USING expression in Chapter 4 of the INFORMIX-SQL Reference for a complete explanation of all the number-formatting features available in I-SQL.
8-39
Now the dollar sign appears right before each number, regardless of its length:
$45 $456 $4,560
Math Functions
You can perform calculations using any of the following six built-in math functions (or aggregates):
TOTAL OF MIN OF MAX OF AVERAGE OF PERCENT
Adds the values in a column for all rows selected. Prints the smallest (minimum) value in a column for all rows selected. Prints the largest (maximum) value in a column for all rows selected. Calculates the average of the values in a column for all rows selected. Calculates the percentage of all rows selected that are in a group. (Refer to Chapter 6 of the Informix Guide to SQL: Reference, Version 4.1 for details). Counts the number of rows in the table or group you specify.
COUNT
Totaling a Column
The following sample report lists information about selected items in the stock table. In addition, it indicates the total number of these items on order.
Unit
Quantity
5 5 5 5 5 5 5 5
5 10 5 5 1 10 5 5 46
8-41
The report specication that produced this report is shown in Figure 8-12:
database stores2 end select items.stock_num, items.manu_code, quantity, description, unit from items, stock where items.stock_num = stock.stock_num and items.manu_code = stock.manu_code and items.stock_num = 5 end format page header print "Stock Number", column 15, "Manufacturer", column 30, "Description", column 50, "Unit", column 60, "Quantity" skip 2 lines on every row print stock_num, column 15, manu_code, column 30, description, column 50, unit, column 60, quantity on last row skip 1 line print column 20, "Total Quantity on Order: ", column 55, total of quantity using "###" end Figure 8-12 Calculating the total of a column
To add all the orders, use the ON LAST ROW control block with a PRINT statement that contains the TOTAL OF function. Specify TOTAL OF, followed by the name of the column you want to total.
Unit
Quantity
5 5 5 5 5 5 5 5
10 5 5 5 10 5 5 1 46 8
8-43
The report specication that produced this report is shown in Figure 8-13:
database stores2 end select items.stock_num, items.manu_code, quantity, description, unit from items, stock where items.stock_num = stock.stock_num and items.manu_code = stock.manu_code and items.stock_num = 5 end format page header print "Stock Number", column 15, "Manufacturer", column 30, "Description", column 50, "Unit", column 60, "Quantity" skip 2 lines on every row print stock_num, column 15, manu_code, column 30, description, column 50, unit, column 60, quantity on last row skip 1 line print column 20, column 55, total skip 1 line print column 20, column 55, count end Figure 8-13
"Total Quantity on Order: ", of quantity using "###" "Total Number of Orders: ", using "###"
The ON LAST ROW control block prints the number of orders along with the total quantity of each order.
Group Functions
In addition to arithmetic operators and math functions, I-SQL contains functions that you can use to perform calculations on groups of information in a report. The group functions, for example, let you calculate subtotals or interim results. The group functions you can use in your report specications include the following:
GROUP TOTAL OF GROUP COUNT GROUP MIN OF GROUP MAX OF GROUP PERCENT GROUP AVERAGE OF
Any time you use a group function for a column, you also must ORDER BY that column in the SELECT or READ section. To perform calculations on groups of rows in your report, use the group functions in the AFTER GROUP OF control block of the FORMAT section. For example, the report statement in Figure 8-14 on page 8-46 sorts items by stock number and prints the total quantity on order for each item.
8-45
In the example, the stock_num column in the items table is given the display label stockno. ACE orders and groups the output by the values in the stockno column. (The use of display labels is described in the SELECT Section discussion in Chapter 4 of the INFORMIX-SQL Reference.)
database stores2 end output left margin 0 end select items.stock_num stockno, items.manu_code, description, unit, quantity from items, stock where items.stock_num = stock.stock_num and items.manu_code = stock.manu_code order by stockno end format page header print "Stock Number", column 15, "Manufacturer", column 30, "Description", column 50, "Unit", column 60, "Quantity" skip 2 lines on every row print stockno, column 15, manu_code, column 30, description, column 50, unit, column 60, quantity after group of stockno skip 1 line print column 20, "Total Quantity on Order: ", column 55, group total of quantity using "###" skip 2 lines end Figure 8-14 The AFTER GROUP OF and GROUP TOTAL OF functions in a report
Displaying a Report
Here is a portion of the sample report generated by the report specication in Figure 8-14:
Unit
Quantity
1 1 1 1 1 1
1 1 1 1 1 1 6
2 2
HRO HRO
baseball baseball
case case
1 1 2
3 3 3
1 1 1 3
4 4 4 4
1 1 1 1 4
Displaying a Report
You can display report output in several ways:
Displayed on your screen Printed on a printer Written to a le Piped as input to another program
Specify how you want the report routed in the OUTPUT section of your report specication. You also can use the OUTPUT section to change the margins and page length. The OUTPUT section in a report specication must appear immediately before the SELECT section (or the READ section).
Creating and Printing Reports 8-47
Displaying a Report
When you run the report, I-SQL creates a le named cust_rep and writes the report results in it.
modication. However, you might occasionally nd it necessary to add a feature. For example, a C function called from ACE might make statistical computations on the data presented in a report and add these to the report. For more information on calling C functions from ACE, see Chapter 6 of the INFORMIX-SQL Reference. After you have written the le containing your C functions, you must compile the les and link the necessary library functions to create a custom version of sacego. For information on the methods that you can use to simplify the creation and compiling process, see Chapter 4 of the INFORMIXSQL Reference.
8-49
Chapter
Changing the Structure of a Table 5 Using the Schema Editor 6 Adding a Column to a Table 6 Modifying a Column in a Table 7 Dropping a Column from a Table 7 Transactions 8 9
Audit Trails 9 Comparing Audit Trails and the Transaction Log Views 10
9-2
Chapter Overview
This chapter explains how to modify the structure of an INFORMIX-SQL (I-SQL) database and table using the I-SQL menu system. It also describes ways to ensure database integrity and discusses data types and indexes. The following topics are considered:
Deleting a database Removing a table or index Renaming a table Renaming, adding, or dropping a column from a table Protecting the integrity of your database with transactions Protecting the integrity of a table with audit trails Creating dynamic windows on your database with views Selecting the appropriate data type for a column Calculating column and row length in a table Using strategies when indexing columns
You must have the appropriate database or table privileges to perform these operations. See the Informix Guide to SQL: Reference, Version 4.1 and the Informix Guide to SQL: Tutorial, Version 4.1, for more information on privileges and for the syntax and usage for the SQL statements you use to change the structure of a database.
Database Structure and Integrity 9-3
Before you rename a table or remove a table or index, be sure the database containing the table or index is the current database.
Removing a Table
You can remove a table from a database by running the DROP TABLE statement or by using the Drop option on the TABLE menu. When you select the Drop option on the TABLE menu, I-SQL prompts you to enter the name of the table you want to drop. You are then asked to conrm that you do want to drop the table. If you change your mind, you can press N and the table is untouched. Press Y and I-SQL drops the table from the database. Note: Be very careful when you drop a table. I-SQL deletes the table you specify. If you accidentally delete the wrong table, you must recreate the table and restore all the data from a backup copy; if you do not have a backup, you must re-enter the data.
Removing an Index
Use the DROP INDEX statement to remove an index. The general syntax is
DROP INDEX index-name
where index-name is the name of the index you want to remove. If you accidentally remove the wrong index, you can easily recreate it with the CREATE INDEX statement.
Renaming a Table
Use the RENAME TABLE statement to change the name of an existing table. The general syntax is
RENAME TABLE oldname TO newname
where oldname is the current name of the table and newname is the name you want to assign to it. Note: When you rename a table you have referred to in reports, screen forms, or I-SQL command les, you need to change those references after you rename the table. For reports and screen forms, you should update the specications and then recompile them. For I-SQL command les, you can just change the references.
9-4
Removing a Database
You remove a database by running the DROP DATABASE statement or by using the Drop option on the DATABASE menu. You must own all the tables in the database or have DBA status to drop a database. If you want to drop the current database, you must rst run the CLOSE
DATABASE statement to close it. The syntax for this statement is CLOSE DATABASE
The Drop option on the DATABASE menu removes a database. When you select the Drop option, I-SQL prompts you to enter the name of the database you want to drop. You are then asked to conrm that you do want to drop the database. If you change your mind, press N and the database is untouched. Press Y and I-SQL drops the database. Note: Be very careful when you drop a database. I-SQL deletes all tables, indexes, and data from the database. I-SQL also removes the database directory if all the les in the directory belong to the database. If the database directory contains les that do not belong to the database, I-SQL removes only the database les and leaves the rest of the directory intact.
Rename a column Add a column Delete a column Change the data type of a column Add a UNIQUE CONSTRAINT to a column Drop a UNIQUE CONSTRAINT from a column
You can make any of these changes to a table that you create. However, you cannot change the structure of a table created by another person unless you are granted ALTER privilege for that table. You can only change the structure of tables that belong to the current database. If you try to change a table that does not belong to the current database, I-SQL displays an error message.
9-5
You can change the structure of a table by using an SQL statement or by using the table schema editor available from the TABLE menu. This section demonstrates the use of the table schema editor. To use SQL statements to change the structure of a table, see the discussion of ALTER TABLE and other SQL statements in Chapter 6, Syntax, in Informix Guide to SQL: Reference, Version 4.1.
9-6
3. Select the Exit option. Then select Build-new-table to make the table addition permanent. I-SQL makes the changes to the database table and returns you to the TABLE menu.
9-7
Transactions
2. Select the Drop option by pressing the d key. I-SQL displays the REMOVE menu, with a message reminding you that this change will delete data when you select Build-new-table.
REMOVE clients : Yes No Deletes the highlighted column from the table. ----- Page 1 of 1 ----- mydata --------------- Press CONTROL-W for Help ------Column Name customer_num fname lname company address1 address2 city state zipcode phone Type Serial Char Char Char Char Char Char Char Char Char Length Index Nulls Unique No Yes Yes Yes Yes Yes Yes Yes Dups Yes Yes
15 15 20 20 20 15 2 5 18
Any data in this column will be lost when you select Exit, Build.
3. Select the Yes option from the REMOVE menu if you want to delete the column; select No and the table is untouched. If you select the Yes option, I-SQL removes the column from the screen and returns to the ALTER TABLE menu. 4. Select Exit, then select Build-new-table. If you decide you do not want to remove the column, select the Discard-new-table option. I-SQL restores the table schema to its prior state.
Transactions
A transaction is a series of operations on a database that you want I-SQL to complete entirely or not at all. For example, if you are writing an accounting program, you might want I-SQL to perform several operations as a unit, to ensure a correct balance. Multiple tables might be affected in the course of completing a series of updates or inserts, and data in the tables must remain in balance. Transactions give you the ability to treat multiple operations as a single transaction. By using transactions, you can ensure the integrity of the data throughout the database.
9-8
Audit Trails
If you are working within the I-SQL menu system on a database with transactions, a TRANSACTION menu appears whenever you attempt to open a new database, run a form, select a user-menu, run a report, or leave the I-SQL menu system without terminating the current transaction. The TRANSACTION menu asks you to commit or roll back (discard) any transactions executed since the transaction log was last updated. For complete information about transactions and the SQL statements used with transactions, refer to Chapters 5 and 7 in the Informix Guide to SQL: Tutorial, Version 4.1 and to Chapter 6 in the Informix Guide to SQL: Reference, Version 4.1.
Audit Trails
An audit trail is a le that contains a history of all additions, deletions, updates, and other manipulations of a database table. The purpose of an audit trail is similar to that of a transaction log. Each is used to maintain a record of modications to a database, and each can be used to update backup copies of a database.
I-SQL records all modications to a database in a transaction log. An audit trail records modications to a single table.
With audit trails, you can record modications to a single important table
without incurring the system expense of maintaining a transaction log on the entire database.
Unlike transactions, audit trails do not protect against statements that fail
to run to completion. For more information about the use of audit trails, refer to Chapter 6, Syntax, in the Informix Guide to SQL: Reference, Version 4.1.
9-9
Views
Views
In certain instances, you might want a user to work with only part of a database, especially if it contains information that you want to remain condential. With I-SQL, you can control what the user sees by creating a dynamic window on the database called a view. Views have the following two advantages over tables:
You can create a view so that I-SQL makes sure that any data entered or
updated by the user satises one or more preconditions. For example, you can create a view that allows the user to work only with customers in California. The user cannot query on or enter data about a customer who lives in Oregon. This way, you can prevent a user from entering information that will not be accessible through the view. For more information about the use of views, refer to Chapter 11, Security and Views, in the Informix Guide to SQL: Tutorial, Version 4.1 and Chapter 6, Syntax, in the Informix Guide to SQL: Reference, Version 4.1.
Index
Index
This index covers both the User and the Reference Manual. Page numbers that end in U can be found in the User, and those that end in R can be found in the Reference Manual. Boldface page numbers indicate the main discussion of a topic. Special symbols are listed in ASCII order at the end of the index.
A
ACE report calling C functions 6-4R DEFINE section in specification file 6-4R example 6-33R, 6-35R FORMAT section in specification file 6-4R how to compile 6-8R steps in creating 8-4U using sacego 6-32R using saceprep 6-8R ACE report writer addition 8-36U AFTER GROUP OF control block 8-34U, 4-43R aggregates 8-36U arithmetic 8-36U ASCII expression 4-71R ASCII statement 4-16R AVERAGE aggregate 8-40U BEFORE GROUP OF control block 8-34U, 4-45R BOTTOM MARGIN statement 8-26U, 4-27R calculations 8-36U calling C functions from 8-49U clauses in 8-20U, 4-12R CLIPPED expression 4-73R COLUMN expression 4-74R column headings 8-29U command line options 4-8R comments 8-21U compiling a report specification 8-13U, 8-18U, 4-5R compound statement 4-55R control block 8-20U, 8-27U, 4-41R
correcting a report specification 8-18U COUNT aggregate 8-40U, 8-43U creating a report specification 8-11U CURRENT expression 4-75R custom report 8-27U DATABASE section 8-8U, 4-13R, 4-14R DATE expression 4-76R DATE( ) function 4-77R DAY( ) function 4-78R default report 8-26U DEFINE section 4-13R definition of 1-20U, 8-4U displaying a report 8-47U division 8-36U END keyword 8-20U error messages 8-19U, 4-11R EVERY ROW statement 8-26U, 4-39R expressions 4-10R expressions, formatting 4-86R filename conventions 4-9R fill characters 8-38U, 8-39U FIRST PAGE HEADER control block 4-47R FOR statement 4-56R FORMAT section 8-10U, 8-22U, 8-26U, 4-13R formatting a report 8-25U formatting number expressions 8-37U, 4-86R generating a default report specification 8-12U GROUP aggregate 8-45U grouping data 8-33U, 4-42R headers 8-27U IF THEN ELSE statement 4-57R INPUT section 4-13R joins 8-23U leading currency symbol 8-39U LEFT MARGIN statement 8-26U, 4-24R LET statement 4-59R LINENO expression 4-79R math functions 8-40U MAX aggregate 8-40U MDY( ) function 4-80R menus 4-5R MIN aggregate 8-40U MONTH( ) function 4-81R multiplication 8-36U NEED statement 4-61R
number expressions, formatting 4-86R ON EVERY ROW control block 8-30U, 4-49R ON LAST ROW control block 4-51R OUTPUT section 8-25U, 8-47U, 4-13R PAGE HEADER control block 8-28U, 4-52R PAGE LENGTH statement 8-26U, 4-28R page numbers 8-30U PAGE TRAILER control block 8-11U, 4-54R PAGENO expression 8-30U, 4-82R PARAM statement 4-18R parentheses 8-37U PAUSE statement 4-62R PRINT FILE statement 4-65R PRINT statement 4-63R PRINT USING statement 8-37U PROMPT FOR statement 4-21R READ section 4-13R READ statement 4-33R report specifications 4-12R, A-34R REPORT TO statement 4-23R RIGHT MARGIN statement 4-25R running a report 8-14U, 4-5R sample report specification 8-7U SELECT section 8-8U, 8-22U, 4-13R SELECT statement 4-30R selecting all rows and columns 8-23U selecting data for a report 8-22U selecting data from several tables 8-23U SKIP statement 4-66R SKIP TO TOP OF PAGE statement 4-67R SPACES expression 4-83R subtraction 8-36U summary of sections 8-20U, 4-13R TIME expression 4-84R TODAY expression 4-85R TOP MARGIN statement 8-26U, 4-26R TOP OF PAGE statement 4-29R TOTAL aggregate 8-40U trailers 8-27U USING expression 8-37U, 4-86R using with menus 4-5R WEEKDAY( ) function 4-93R WHILE statement 4-68R WORDWRAP expression 4-94R YEAR( ) function 4-95R
Index
ACEGO, running a compiled report with H-11R ACEPREP, compiling report specifications with 6-8R, H-10R Active table definition of 3-5U, 5-4U selecting a different 5-4U ADD NUMBER menu, schema editor 2-15U Add option ALTER TABLE menu 2-24U CREATE TABLE menu 2-11U, 2-13U PERFORM 3-12U, 3-19R ADD STARTING NUMBER screen, schema editor 2-18U ADD TYPE menu, schema editor 2-14U, 2-18U Adding data, in PERFORM 3-12U AFTER control block, in PERFORM 2-64R AFTER GROUP OF control block 8-10U AFTER GROUP OF control block, in ACE reports 8-34U, 4-43R Aggregate functions, listed 2-74R Alias, table I-13R Alter option, TABLE menu 2-10U, 2-24U, 1-17R ALTER TABLE menu Build-new-table Exit option 2-24U Drop option 9-7U options 2-24U ALTER TABLE statement C-7R, C-11R, C-19R ANSI C-5R, C-16R, C-35R, C-39R, C-47R ANSI-compliance and DBANSIWARN B-8R and reserved words F-1R, F-9R -ansi flag B-8R Arrows in syntax diagrams Intro-7R AS keyword F-6R ASCII character chart E-2R ASCII character set C-2R, C-3R, C-5R, C-9R, C-11R, C-24R, C-31R ASCII collation C-4R, C-18R, C-23R ASCII expression, in ACE reports 4-71R
ASCII file and reports 4-17U and UNLOAD statement 4-17U as input to an application 4-17U retrieving data for a report 8-24U ASCII statement, in ACE reports 8-25U, 4-16R At (@) symbol. See Trailing currency symbol. ATTRIBUTES section AUTONEXT 2-29R COLOR 6-20U, 2-30R COMMENTS 6-21U, 2-33R DEFAULT 6-23U, 2-34R, I-10R definition of 6-18U description of 6-13U, 6-17U, 2-7R DOWNSHIFT 6-22U, 2-35R for multiline editor 3-18U FORMAT 2-36R form-specification file 6-13U how to enter 6-19U INCLUDE 6-25U, 2-38R INVISIBLE 6-21U, 2-40R keywords 6-18U LOOKUP 2-41R NOENTRY 2-43R NOUPDATE 2-44R PICTURE 2-45R PROGRAM I-11R QUERYCLEAR 2-47R REQUIRED 2-48R REVERSE 2-49R RIGHT 2-50R rules for assigning 6-20U syntax 2-28R UPSHIFT 6-22U, 2-51R VERIFY 6-27U, 2-52R WORDWRAP 3-18U, 2-53R ZEROFILL 2-55R Audit trail definition of 9-9U versus a transaction log 9-9U AUTONEXT attribute 2-29R
Index
B
BEFORE control block, in PERFORM 2-63R BEFORE GROUP OF control block, in ACE reports 8-34U, 4-45R Blank characters as list separators Intro-7R default character value 2-9R Blob querying with INFORMIX-OnLine I-5R specifying external programs in forms I-10R specifying in forms I-9R supported in OnLine Intro-14U transferring with LOAD and UNLOAD I-6R viewing in PERFORM I-5R BOTTOM MARGIN statement, in ACE reports 8-26U, 4-27R Bourne shell how to set environment variables B-4R .profile file B-2R BYTE data type defining columns I-3R specifying in forms I-9R supported in OnLine Intro-14U
C
C function calls in ACE reports 8-49U, 6-8R in PERFORM forms 6-14R C functions calling from ACE 8-49U, 6-6R calling from PERFORM 6-32U, 6-9R calling in report specification file 6-6R declaring in report specification file 6-4R, 6-5R in expressions 6-10R, 6-14R passing values to 6-18R to control PERFORM screens 6-22R C program structure return value macros 6-21R strreturn macro 6-21R userfuncs array 6-17R valueptr 6-16R
C shell how to set environment variables B-4R .cshrc file B-2R .login file B-2R cace program, used to customize sacego 6-32R Calculations in reports 8-36U CALL keyword in ACE report specification file 6-7R in PERFORM form specification file 6-10R Calling C functions in ACE 6-6R in PERFORM 6-32U catalog table in stores demonstration database A-6R Category, NLS C-2R CHANGE ANYWAY menu, schema editor 9-7U CHAR data type definition of 2-15U determining length 2-15U in forms 3-10R in NLS C-4R, C-6R, C-10R, C-19R Character set defined C-3R mentioned C-24R, C-31R CHOOSE DATABASE screen, selecting options from 2-9U Choose option, SQL menu 7-14U, 1-13R CLIPPED expression, in ACE reports 4-73R CLOSE DATABASE statement 9-5U Clustered indexes 2-21U Collation C-2R, C-4R, C-5R, C-9R, C-11R, C-14R, C-21R, C-27R COLLCHAR environment variable interaction with DBNLS C-17R, C-20R mentioned C-2R, C-5R, C-12R settings C-20R syntax C-19R COLOR attribute in PERFORM 6-20U, 2-30R intensity list 2-30R
Index
Color, setting INFORMIXTERM for B-35R COLUMN expression, in ACE reports 4-74R Columns adding, using the TABLE menu 9-6U assigning a data type 2-14U, 2-18U CHAR data type 2-15U column names 1-6U correspondence between data type and PERFORM field entry 3-13U DATE data type 2-17U DATETIME data type 2-17U DECIMAL data type 2-15U defining a column 2-12U defining for a table 2-12U definition of 1-6U displaying with the Info option 7-17U dropping, using the ALTER TABLE menu 9-7U FLOAT data type 2-16U in stores demonstration database A-4R to A-7R in stores demonstration database tables A-4R indexing 2-19U INTEGER data type 2-16U INTERVAL data type 2-18U join 1-9U, 2-26R joining in multiple-table forms 5-7U locale-sorted C-6R, C-8R MONEY data type 2-17U naming conventions 2-13U naming with the Add option 2-13U NULL value in 2-21U number data type 2-15U searching for 1-8U searching for within rows 1-8U SERIAL data type 2-16U SMALLFLOAT data type 2-16U SMALLINT data type 2-16U Comma symbol. See Thousands separator. Command files guidelines for naming 7-14U how to choose 7-15U saving statements 7-14U
Command line accessing ACE 4-8R accessing DATABASE menu H-5R accessing FORM menu H-2R accessing I-SQL modules H-1R accessing PERFORM H-9R accessing QUERY-LANGUAGE menu H-4R accessing REPORT menu H-3R accessing TABLE menu H-6R accessing USER-MENU menu H-5R compiling a customized report form H-10R compiling a customized screen form H-7R using ACEGO H-11R using ACEPREP H-10R using sperform 2-6R Comments displaying on screen in PERFORM 6-21U in SQL statements 7-16U including in a report specification 8-21U COMMENTS attribute, in PERFORM 6-21U, 2-33R Compile option FORM menu 1-11R REPORT menu 1-15R COMPILE REPORT menu 8-19U Compiling definition of 6-7U form specifications 1-11R, 6-14R report specifications 8-18U, 6-8R, H-10R reports 1-15R with saceprep 6-8R with sformbld 6-14R Compiling form specifications H-7R Composite joins, in PERFORM 2-57R Compound statement, in ACE 4-55R COMPRESS keyword I-9R CONNECT statement, and INFORMIXSERVER environment variable B-33R Connection setting the INFORMIXCONRETRY environment variable B-30R setting the INFORMIXCONTIME environment variable B-31R Index 5
Consistency checking defined C-7R, C-16R mentioned C-7R, C-27R, C-47R overriding with Open NLS C-8R Control blocks AFTER GROUP OF 4-43R BEFORE GROUP OF 4-45R FIRST PAGE HEADER 4-47R FORMBUILD 2-62R in ACE specification file 8-20U, 8-27U, 6-6R in FORMAT section of ACE report 4-41R ON BEGINNING 6-12R ON ENDING 6-12R ON EVERY ROW 4-49R ON LAST ROW 4-51R PAGE HEADER 4-52R PAGE TRAILER 4-54R Conventions typographical Intro-5U, Intro-5R cperf program, used to customize sperform 6-32R Create Database screen 2-6U Create option DATABASE menu 2-6U, 1-8R TABLE menu 1-17R CREATE TABLE menu building a schema with 1-17U, 2-12U correcting mistakes 2-12U definition of 2-11U CREATE TABLE statement 7-8U, C-4R, C-7R, C-11R, C-19R CREATE VIEW statement, WITH CHECK OPTION 9-10U Creating a menu with the User-menu 5-8R a script menu 5-24R Criteria, for database query 4-10U crtcmap utility C-24R Current database changing 2-8U definition of 2-7U CURRENT expression, in ACE reports 4-75R Current list definition of 4-8U in PERFORM 2-62R
scanning rows with Next and Previous options 4-9U with multiple-table forms 5-14U Current option changing 1-13U definition of 1-12U in multiple-table forms 5-14U in PERFORM 3-20R Current statement, definition of 7-4U Cursor movement, in PERFORM 6-17U customer table columns in 1-7U in stores demonstration database A-4R Customized screen form, FORMBUILD 2-5R cust_calls table in stores demonstration database A-6R
D
Data adding to a database with PERFORM 3-12U checking in PERFORM fields 3-15U, 3-15R confirming your entry in PERFORM fields 3-15U definition of 1-4U displaying on the screen with PERFORM 5-10U, 2-12R entering for a menu 5-10R entering in a table using a screen form 3-3U entering in fields with PERFORM 3-13U entering into fields with PERFORM 3-9R entering with the User-menu 5-13R how it is stored 1-4U how to query on 4-3U including from multiple tables in one form 3-5U retrieving from a database 1-7U updating in PERFORM 3-35R verifying 5-10U Data type assigning to a column 2-14U, 2-18U BYTE Intro-14U, I-3R, I-11R CHAR 2-15U
Index
CHAR, in forms 3-10R CHAR, in NLS C-4R, C-6R, C-10R, C-19R choosing with INFORMIX-OnLine I-3R DATE 2-17U DATETIME 2-17U DATETIME, in forms 3-11R DATE, in forms 3-11R DATE, in NLS C-10R DECIMAL 2-15U DECIMAL, in forms 3-10R DECIMAL, in NLS C-10R definition of 3-9R FLOAT 2-16U FLOAT, in forms 3-11R FLOAT, in NLS C-10R for number columns 2-15U formatting in forms 2-36R INTEGER 2-16U INTEGER, in forms 3-10R INTERVAL 2-18U INTERVAL, in forms 3-11R MONEY 2-17U MONEY, in forms 3-10R MONEY, in NLS C-10R NCHAR C-4R, C-6R, C-10R, C-19R NVARCHAR C-4R, C-6R, C-10R, C-19R SERIAL 2-16U SERIAL, in forms 3-10R SMALLFLOAT 2-16U SMALLFLOAT, in forms 3-10R SMALLFLOAT, in NLS C-10R SMALLINT 2-16U SMALLINT, in forms 3-10R synonyms 3-9R table of 2-17U TEXT Intro-14U, I-3R, I-11R VARCHAR Intro-14U, I-3R VARCHAR, in NLS C-4R, C-6R, C-10R, C-19R what it does 2-14U Database adding data using PERFORM 3-12U changing the current 2-8U changing the structure 9-3U creating tables in 2-9U creating through the Main menu 2-5U current 2-7U definition of 1-4U how to retrieve data 1-7U
map of stores demonstration A-8R naming conventions 2-6U querying on 1-7U, 4-3U relational 1-9U removing 9-5U removing a table 9-4U removing an index 9-4U renaming a table 9-4U retrieving information from 1-7U selecting a different current 2-8U stores demonstration described Intro-8U, A-1R stores2 Intro-11R system files in 2-8U tables in demonstration 5-4U user-menu for 1-25U Database engine features Intro-13U Database locale C-2R Database management system definition of 1-3U relational 1-9U DATABASE menu Create option 1-8R Drop option 1-8R Exit option 1-8R how to use 1-8R options 2-6U Select option 1-8R DATABASE section in form specifications 6-12U, 2-6R, 2-9R in forms, WITHOUT NULL INPUT 2-34R in report specifications 8-8U, 4-14R Database server, specifying default for connection B-33R DATE data type default in form specifications 6-24U definition of 2-17U explanation of 2-17U formatting in form 2-36R in forms 3-11R in NLS C-10R DATE expression, in ACE reports 4-76R DATE value formatting B-8R, B-18R DATETIME data type acceptable values 3-11R definition of 2-17U in forms 3-11R
Index
DATE( ) function, in ACE reports 4-77R DAY( ) function, in ACE reports 4-78R DBANSIWARN environment variable B-8R DBAPICODE environment variable C-2R, C-12R, C-23R, C-24R DBDATE environment variable B-8R, C-3R, C-12R, C-41R, C-42R DBDELIMITER environment variable B-11R DBEDIT environment variable B-11R dbexport utility specifying field delimiter with DBDELIMITER B-11R DBFORM environment variable B-12R, C-3R, C-12R, C-25R DBFORMAT environment variable B-14R, C-3R, C-5R, C-6R, C-12R, C-35R, C-38R, C-39R, C-41R, C-42R DBLANG environment variable B-18R, C-3R, C-12R, C-24R, C-41R dbload utility specifying field delimiter with DBDELIMITER B-11R DBMONEY environment variable B-21R, C-3R, C-5R, C-6R, C-12R, C-35R, C-38R, C-40R, C-42R DBNLS environment variable interaction with COLLCHAR C-17R, C-20R mentioned C-2R, C-5R, C-12R settings C-18R syntax C-17R DBPATH environment variable B-23R DBPRINT environment variable B-26R DBREMOTECMD environment variable B-27R dbschema utility definition of 1-17U DBSPACETEMP environment variable B-28R DBTEMP environment variable B-29R DBUPSPACE environment variable B-29R DECIMAL data type definition of 2-15U formatting in form 2-36R in forms 3-10R 8 Index
in NLS C-10R scale and precision 2-15U Decimal separator 4-87R, B-14R, B-21R, C-31R, C-33R, C-35R, C-40R, C-44R Declaring C functions, in ACE 6-4R, 6-5R Default assumptions for your environment B-5R DEFAULT attribute not using with TEXT or BYTE I-10R PERFORM 6-23U with WITHOUT NULL INPUT 2-34R DEFAULT attribute, in PERFORM 2-34R DEFINE section ASCII statement 4-16R declaring a C function 6-4R PARAM statement 4-18R PROMPT FOR statement 4-21R VARIABLE statement 4-19R Delete option, in PERFORM 3-19U Deleting data, in PERFORM 3-19U Delimiters definition of 3-4U FORMBUILD 2-12R Demonstration database Intro-8U, Intro-11R copying A-2R map of A-8R restoring the original database A-3R sample forms 2-3R stores, tables in A-1R tables in 1-5U, 5-4U, A-4R to A-7R Designing a menu with the User-menu 5-5R Detail option, in PERFORM 5-11U, 3-21R Detail table, selecting 5-11U Directory, database 2-8U Display field FORMBUILD 2-12R order 2-20R Display-only field, FORMBUILD 2-12R Distributed query across databases Intro-14U Dollar sign. See Leading currency symbol. Dominant column FORMBUILD 2-27R joins 2-27R
DOWNSHIFT attribute in NLS C-11R in PERFORM 6-22U, 2-35R DROP INDEX statement 9-4U Drop option ALTER TABLE menu 2-24U, 9-7U CREATE TABLE menu 2-11U DATABASE menu 2-6U, 1-8R FORM menu 1-11R REPORT menu 1-15R SQL menu 1-13R TABLE menu 1-17R
E
Editor multiline 3-18U, 3-14R specifying with DBEDIT B-11R specifying with WORDWRAP attribute 3-18U SQL 7-9U system 7-10U ENVIGNORE environment variable B-30R Environment configuration file example B-2R where stored B-3R Environment variable and case sensitivity B-4R COLLCHAR C-2R, C-5R, C-12R, C-17R, C-19R DBANSIWARN B-8R DBAPICODE C-2R, C-12R, C-23R, C-24R DBDATE B-8R, C-3R, C-12R, C-41R, C-42R DBDELIMITER B-11R DBEDIT 2-4R, B-11R DBFORM B-12R, C-3R, C-12R, C-25R DBFORMAT B-14R, C-3R, C-5R, C-6R, C-12R, C-35R, C-38R, C-39R, C-41R, C-42R DBLANG B-18R, C-3R, C-12R, C-24R, C-41R DBMONEY B-21R, C-3R, C-5R, C-6R, C-12R, C-35R, C-38R, C-40R, C-42R DBNLS C-5R, C-12R, C-17R DBPATH B-23R DBPRINT B-26R DBREMOTECMD B-27R
DBSPACETEMP B-28R DBTEMP B-29R DBUPSPACE B-29R default assumptions B-5R defining in environment configuration file B-2R definition of B-2R ENVIGNORE B-30R hierarchy of precedence C-13R, C-31R, C-33R, C-34R, C-37R, C-38R, C-40R, C-41R, C-47R how to set in Bourne shell B-4R how to set in C shell B-4R how to set in Korn shell B-4R INFORMIX environment variables, listing B-6R INFORMIXCONRETRY B-30R INFORMIXCONTIME B-31R Informix-defined C-2R, C-12R, C-13R INFORMIXDIR B-12R, B-19R, B-32R, C-24R, C-25R INFORMIXSERVER B-33R INFORMIXSHMBASE B-33R INFORMIXSTACKSIZE B-34R INFORMIXTERM B-35R, D-1R, D-18R LANG B-20R, C-2R, C-12R, C-13R, C-15R, C-16R, C-21R, C-24R, C-25R, C-31R, C-34R, C-40R, C-42R, C-43R, C-49R language and formatting C-12R LC_COLLATE C-2R, C-4R, C-5R, C-6R, C-7R, C-12R, C-14R, C-16R, C-27R LC_CTYPE C-2R, C-5R, C-7R, C-12R, C-16R, C-24R, C-29R LC_MONETARY C-2R, C-5R, C-12R, C-14R, C-31R, C-35R, C-41R, C-42R LC_NUMERIC C-2R, C-5R, C-12R, C-35R, C-42R listed B-6R listed, for NLS B-7R, B-39R listed, for UNIX B-7R meta-environment C-12R NLS environment variables, listing B-7R, B-39R ONCONFIG B-36R overriding a setting B-3R, B-30R PATH B-40R PSORT_DBTEMP B-36R rules of precedence B-6R Index 9
setting at the command line B-2R setting in a shell file B-2R SQLEXEC B-38R SQLRM B-38R SQLRMDIR B-39R TERM B-41R TERMCAP B-41R TERMINFO B-42R UNIX environment variables, listing B-7R where to set B-2R X/Open-defined C-12R, C-13R Errors,correcting in SQL statements 7-12U EVERY ROW statement, in ACE reports 8-30U, 4-39R Exit option ALTER TABLE menu 2-24U CREATE TABLE menu 2-11U DATABASE menu 2-6U, 1-8R FORM menu 1-11R PERFORM 3-22R REPORT menu 1-15R SQL menu 1-13R TABLE menu 1-17R USER-MENU menu 1-18R Explicit NLS environment defined C-7R, C-20R disadvantages of C-7R example C-21R mentioned C-4R, C-5R, C-19R Expressions definition of 6-10R, 6-14R in ACE 4-10R in PERFORM control block 6-10R, 6-14R Extension checking, specifying with DBANSIWARN B-8R
F
Facilities for database management 1-16U in INFORMIX-SQL 1-16U report writing 1-20U schema editor 1-17U screen form 1-18U structured query language 1-23U User-menu 1-25U
Field tag assignments 6-17U definition of 6-12U FORMBUILD 2-12R Field width explanation of 6-17U FORMBUILD 2-12R Fields character, in PERFORM 3-13U checking your data entry in PERFORM 3-15U confirming your data entry in PERFORM 3-15U correspondence to columns 1-18U, 3-4U DATETIME, in PERFORM 3-14U DATE, in PERFORM 3-14U definition of 1-18U, 3-3U delimiters, in PERFORM 2-59R display 2-12R display order 2-20R displaying text in color 6-20U display-only 2-24R editing in PERFORM 3-17U editing, in PERFORM 3-17U entering data, in PERFORM 3-13U FORMBUILD 2-12R INTERVAL, in PERFORM 3-15U join 5-3U linked to database columns 2-22R lookup 2-22R making text invisible 6-21U MONEY, in PERFORM 3-14U number, in PERFORM 3-13U querying on in PERFORM 4-11U too short for search 4-15U File command 7-13U environment configuration B-2R output, formatting in PERFORM 4-20U perform.out 4-18U saving current statements in 7-13U sending query results with the Output option 7-16U shell B-2R temporary for OnLine B-28R temporary for SE B-29R writing reports to 8-48U
10
Index
File extension for compiling ACE reports 6-8R for compiling PERFORM forms 6-14R .ACE 4-6R, 4-7R, 4-9R, 6-8R .ARC 4-7R, 4-8R, 4-9R .C 6-32R .DAT 2-23U .DBS 2-8U .EC 6-32R .ERR 2-5R, 4-7R, 4-9R .FRM 6-8U, 2-5R, B-12R .IDX 2-23U .IEM B-18R .OUT 4-18U .PER 6-8U, 2-5R, 6-14R .SQL 7-14U Fill characters, definition of 8-38U FIRST PAGE HEADER control block, in ACE reports 4-47R FLOAT data type definition of 2-16U formatting in form 2-36R in forms 3-11R in NLS C-10R FOR statement, in ACE reports 4-56R FORM menu Compile option 1-11R Drop option 1-11R Exit option 1-11R Generate option 1-11R Modify option 1-11R New option 1-11R Run option 1-11R, 3-4R FORM OUTPUT FILE menu, in PERFORM 3-25R Form specifications ATTRIBUTES section 6-13U, 2-7R, 2-20R changing default values 6-23U choosing tables for 6-6U compiling 6-7U, 1-11R, H-7R controlling case of input 6-22U correcting errors in 6-8U customizing 2-4R DATABASE section 6-12U, 2-6R, 2-9R default 6-3U, 6-7U, 2-4R, 2-5R definition of 6-3U editing 1-11R field tag assignments 6-17U field tags in 6-12U
files that make up 6-8U INSTRUCTIONS section 6-32U, 2-7R, 2-56R joining fields in 6-28U JOINING keyword in 6-31U lookup joins on 6-30U maximum number of tables in 6-6U modifying 6-4U, 6-10U naming 6-5U sample file 2-82R SCREEN section 6-12U, 2-7R, 2-10R sections in 6-10U, 2-6R specifying acceptable values in 6-25U TABLES section 6-12U, 2-7R, 2-18R using today as default date 6-24U verify joins with 6-30U verifying input in 6-27U Format date data 2-36R, 4-88R, B-8R, B-18R, C-46R monetary data 4-86R, B-14R, C-31R, C-44R numeric data 2-36R, 4-86R, B-14R, C-35R, C-44R FORMAT attribute in NLS C-11R, C-31R, C-33R, C-37R, C-40R, C-41R, C-43R in PERFORM 2-36R FORMAT section of report specification AFTER GROUP OF control block 8-10U, 4-43R BEFORE GROUP OF control block 4-45R control blocks 4-41R EVERY ROW statement 4-39R FIRST PAGE HEADER control block 4-47R FOR statement 4-56R IF THEN ELSE statement 4-57R LET statement 4-59R NEED statement 4-61R ON EVERY ROW control block 8-10U, 4-49R ON LAST ROW control block 8-11U, 4-51R PAGE HEADER control block 8-10U, 4-52R PAGE TRAILER control block 8-11U, 4-54R PAUSE statement 4-62R PRINT FILE statement 4-65R Index 11
PRINT statement 4-63R sample section 8-10U SKIP statement 4-66R SKIP TO TOP OF PAGE statement 4-67R WHILE statement 4-68R Format string, definition of 8-38U Formatting ACE 4-86R data types in form 2-36R report 8-25U FORMBUILD transaction form generator ATTRIBUTES section 2-7R BEGIN keyword 2-80R BELL keyword 2-79R compiling a customized form 2-4R, 6-14R, H-7R control block 2-62R creating a customized form 2-4R CURRENT keyword 2-75R current list 2-62R DATABASE section 2-6R DATE format 2-36R default form-specification file 2-4R, 2-5R delimiters 2-12R display field 2-12R display-only field 2-12R, 2-47R dominant column 2-27R END keyword 2-80R EXITNOW keyword 2-77R field 2-12R field tag 2-12R field width 2-12R FLOAT format 2-36R forms, sample 2-3R INSTRUCTIONS section 2-7R operating system, use in form creation 2-5R, H-7R ORDER INFORMATION screen 2-84R REVERSE keyword 2-79R SCREEN section 2-7R sformbld 2-6R SMALLFLOAT format 2-36R subscripting a CHAR column 2-13R TABLES section 2-7R TODAY 2-75R verify join 2-27R Forms ATTRIBUTES section 6-13U choosing which tables to include 6-6U 12 Index
compiling 1-11R compiling the default specification 6-7U compiling, linking, and running 6-32R creating and compiling custom 2-4R creating with INFORMIX-OnLine I-8R creating with the operating system 2-5R DATABASE section 6-12U default 1-11R entering data on a screen form 3-3U graphics characters in 2-15R how to create 6-4U how to name 6-5U modifying an existing one 6-10U multiple-page 4-17U multiple-table 5-3U orderform 5-5U, 5-8U querying on 4-10U running 1-11R screen form 1-18U SCREEN section 6-12U specifying acceptable values 6-25U specifying remote databases I-12R specifying remote tables I-12R TABLES section 6-12U using default field values 6-23U using synonyms for external tables I-13R verifying input 6-27U with blobs I-9R with external tables I-13R with VARCHARs I-8R Function library pf_gettype 6-23R pf_getval 6-25R pf_msg 6-31R pf_nxfield 6-29R pf_putval 6-27R Functions aggregate, listed 2-74R C, calling from ACE 8-49U Execute, in PERFORM 3-16U Help, in PERFORM 3-16U Interrupt, in PERFORM 3-16U math, for ACE reports 8-40U names used as column names F-2R to control PERFORM screens 6-22R
G
Generate option FORM menu 1-11R REPORT menu 1-15R GENERATE REPORT screen 8-12U Global Language Support C-4R GLS C-4R Graphics characters, in forms 2-15R
H
HELP menu guidelines for using 1-16U options of 1-16U Help, how to use 1-16U Highest value operator, in PERFORM 4-14U, 3-31R Highlight, how to move 1-13U
I
Icons in syntax diagrams Intro-7R Identifiers in NLS C-5R, C-9R, C-22R, C-29R Identifiers, rules for menu names 5-16R IF THEN ELSE statement, in ACE reports 4-57R Implicit mapping C-4R, C-6R, C-8R, C-19R Implicit NLS environment advantages of C-19R defined C-6R, C-20R example C-21R mentioned C-5R INCLUDE attribute, in PERFORM 6-25U, 2-38R Indexes ascending 2-21U clustered 2-21U creating 2-19U descending 2-21U displaying with the Info option 7-17U for columns with duplicate values 2-20U removing from a database 9-4U unique 2-20U when to index a table 2-20U
INFO menu options 7-17U with INFORMIX-OnLine I-4R with SQL 7-17U Info option SQL menu 7-17U, 1-13R TABLE menu 2-10U, 1-17R Information lines, in PERFORM 3-8U .informix environment configuration file B-2R Informix extension checking, specifying with DBANSIWARN B-8R INFORMIXCONRETRY environment variable B-30R INFORMIXCONTIME environment variable B-31R Informix-defined environment variable C-2R, C-12R, C-13R INFORMIXDIR environment variable B-12R, B-19R, B-32R, C-24R, C-25R INFORMIX-SE database engine Intro-13U INFORMIXSERVER environment variable B-33R INFORMIXSHMBASE environment variable B-33R INFORMIX-SQL facilities 1-16U how to access 1-3R how to access the User-menu 5-4R Main menu 1-12U, 1-3R menu screens 1-3R text-entry screens 1-4R what is 1-3U INFORMIXSTACKSIZE environment variable B-34R INFORMIXTERM environment variable B-35R, D-1R, D-18R informix.rc file B-2R Insert mode, in PERFORM 3-17U, 3-13R Installation directory, specifying with INFORMIXDIR B-32R INSTRUCTIONS section ABORT 2-73R ADD 2-67R AFTER 2-64R BEFORE 2-63R COMMENTS 2-79R Index 13
COMPOSITES 2-57R DELIMITERS 2-59R DISPLAY 2-71R EDITADD 2-65R EDITUPDATE 2-65R IF-THEN-ELSE 2-80R in form specification 6-32U in form specifications 2-7R LET 2-74R MASTER OF 2-60R NEXTFIELD 2-77R QUERY 2-69R REMOVE 2-70R UPDATE 2-68R INTEGER data type definition of 2-16U in forms 3-10R with display fields 2-9R Intensity attributes, setting INFORMIXTERM for B-35R Interrupt key Intro-12U INTERVAL data type 2-18U acceptable values 3-11R in forms 3-11R INVISIBLE attribute, in PERFORM 6-21U, 2-40R items table in stores demonstration database A-5R
Join columns definition of 5-7U in screen forms 2-26R stores demonstration database columns A-8R JOINING keyword in a form specification 6-31U
K
Keys arrow, with SQL editor 7-9U backspace, in PERFORM 3-16U, 3-17U basic keys for SQL Intro-12U change mode, in PERFORM 3-17U clear screen, in PERFORM 3-17U cursor positioning, in PERFORM 3-16U, 3-12R delete a character, in PERFORM 3-17U delete a character, with SQL editor 7-9U delete forward, in PERFORM 3-17U delete rest of line, with SQL editor 7-10U editing keys, in PERFORM 3-17U editing keys, in SQL 7-9U escape, with SQL editor 7-9U execute, in PERFORM 3-16U fast backspace, in PERFORM 3-16U fast forward, in PERFORM 3-16U field editing, in PERFORM 3-17U, 3-13R for displaying HELP menu 1-16U for leaving a menu 2-9U for moving the highlight 1-13U forward, in PERFORM 3-16U, 3-17U help, in PERFORM 3-16U insert mode, with SQL editor 7-9U interrupt, in PERFORM 3-16U next field, in PERFORM 3-16U repeat data, in PERFORM 3-17U special function, in PERFORM 3-12R Keywords names used as column names F-3R typographic convention Intro-5U, Intro-5R Keywords in ACE COLUMN 8-28U DELIMITER 8-24U
J
Join composite 2-57R definition of 1-9U dominant column 2-27R fields 6-28U fields on screen forms 5-7U field, definition of 5-7U FORMBUILD 2-26R, 2-27R in multiple-table form 5-3U in PERFORM 5-7U in the stores demonstration database 1-9U JOINING keyword 6-31U lookup 5-10U, 6-30U verify 5-10U, 6-30U, 2-27R
14
Index
END 8-18U, 8-20U SPACES 8-28U USING 8-37U Keywords in PERFORM ABORT 2-73R AFTER 2-64R AFTER ADD OF 2-67R AFTER DISPLAY OF 2-71R AFTER QUERY OF 2-69R AFTER UPDATE OF 2-68R ALLOWING INPUT 2-24R ATTRIBUTES 6-13U AUTONEXT 2-29R BEFORE 2-63R BELL 2-79R BY 2-10R COLOR 2-30R COMMENTS 2-33R, 2-79R COMPOSITES 2-57R COMPRESS 2-53R DATABASE 6-12U, 2-9R DEFAULT 2-34R DELIMITERS 2-59R DISPLAYONLY 2-24R DOWNSHIFT 2-35R EDITADD 2-65R EDITUPDATE 2-65R END 6-11U, 2-18R EXITNOW 2-77R FORMAT 2-36R IF-THEN-ELSE 2-80R INCLUDE 2-38R INVISIBLE 2-40R JOINING 6-31U, 2-41R LET 2-74R LOOKUP 6-31U, 2-41R MASTER OF 2-60R NEXTFIELD 2-77R NOT NULL 2-24R NOUPDATE 2-44R OF 2-63R, 2-64R PICTURE 2-45R QUERYCLEAR 2-47R REMOVE OF 2-70R REQUIRED 2-48R REVERSE 2-49R, 2-79R RIGHT 2-50R SCREEN 6-12U, 2-10R SIZE 2-10R TABLES 2-18R TO 6-25U TYPE 2-24R
UPSHIFT 2-51R VERIFY 2-52R WHERE 6-21U, 2-30R WITHOUT NULL INPUT 6-23U, 2-9R WORDWRAP 2-53R ZEROFILL 2-55R Korn shell how to set environment variables B-4R .profile file B-2R
L
LANG environment variable effect of where set on precedence C-15R interaction with DBLANG B-20R lack of standardization C-26R mentioned C-2R, C-12R, C-13R, C-16R, C-21R, C-24R, C-31R, C-34R, C-40R, C-42R, C-43R, C-49R setting default for LC_ variables C-2R, C-14R, C-25R syntax C-26R Language and formatting environment variable C-12R Language supplement C-25R, C-27R, C-48R LC_ variable defined C-12R effect of where set on precedence C-15R lack of standardization C-2R, C-13R, C-16R, C-25R, C-40R LC_COLLATE environment variable database storage of value C-7R, C-16R defined C-27R mentioned C-2R, C-4R, C-5R, C-6R, C-12R, C-14R syntax C-28R LC_CTYPE environment variable database storage of value C-7R, C-16R, C-29R defined C-29R interaction with DBAPICODE C-24R mentioned C-2R, C-5R, C-12R syntax C-30R
Index
15
LC_MONETARY environment variable defined C-31R mentioned C-2R, C-5R, C-12R, C-14R, C-35R, C-41R, C-42R syntax C-5R, C-32R LC_NUMERIC environment variable defined C-35R mentioned C-2R, C-5R, C-12R, C-42R syntax C-36R Leading currency symbol 8-40U, 4-87R, B-14R, B-21R, C-33R, C-40R, C-45R LEFT MARGIN statement, in ACE reports 8-26U, 4-24R LET statement conversion of MONEY to CHAR C-33R, C-37R in ACE reports 4-59R in NLS C-11R, C-46R Levels of menus in a User-menu structure 5-5R Library functions in PERFORM 6-22R pf_gettype( ) 6-23R pf_getval( ) 6-25R pf_msg( ) 6-31R pf_nxfield( ) 6-29R pf_putval( ) 6-27R LINEFEED characters between statements Intro-7R LINENO expression, in ACE reports 4-79R LOAD statement in NLS C-8R, C-11R, C-16R, C-35R, C-40R, C-42R specifying field delimiter with DBDELIMITER B-11R with INFORMIX-OnLine I-7R with VARCHARs and blobs I-7R Locale database locale C-2R defined C-2R mentioned C-16R, C-25R user locale C-2R Locale consistency checking. See Consistency checking. Locale file C-27R Locale variable C-12R, C-13R Locale-sorted columns C-6R, C-8R
LOCK TABLE statement, in PERFORM 3-19R LOOKUP attribute, in PERFORM 2-41R Lookup fields definition of 5-11U, 6-30U in form specifications 6-30U specifying with the LOOKUP attribute 2-22R Lookup joins definition of 6-30U in multiple-table forms 5-10U in PERFORM 5-11U on a screen form 5-10U Loops in syntax diagrams Intro-7R Lowest value operator, in PERFORM 4-14U, 3-31R
M
Main menu accessing 1-12U creating a database 2-5U creating a table 2-9U Database option 1-14U, 2-6U Exit option 1-14U Form option 1-12U, 1-13U, 3-6U, 6-5U, 1-11R, 2-4R how to exit 1-10R map of INFORMIX-SQL menu hierarchy 1-5R Query-language option 1-14U, 7-5U, 1-13R Report option 1-13U, 1-15R shown 1-3R Table option 1-14U, 1-17R User-menu option 1-14U, 1-18R manufact table in stores demonstration database A-7R Mapping file C-24R, C-25R Master option, in PERFORM 5-13U, 3-23R Master-detail relationship Detail menu option, in PERFORM 3-21R introduction to 5-11U Master menu option, in PERFORM 3-23R specifying 2-60R
16
Index
Match, exact in PERFORM query 4-4U Math functions, in ACE reports 8-40U MDY( ) function, in ACE reports 4-80R Menu form file C-25R menuform screen form accessing the sysmenuitems table 5-9R accessing the sysmenus table 5-9R definition of 5-9R entering data in fields 5-15R Menu Name field 5-16R Menu Title field 5-17R Selection Action field 5-22R Selection Number field 5-18R Selection Text field 5-21R Selection Type field 5-19R Menus ADD TYPE 2-14U ALTER TABLE 2-24U calling with the User-menu facility 1-25U CHANGE ANYWAY 9-7U CREATE TABLE 2-11U creating a script 5-24R creating custom with User-menu facility 1-25U, 5-3R creating your own 5-8R current option 1-12U custom (user-menus) 1-25U DATABASE 2-6U designing 5-5R entering data 5-10R FORM 1-11R HELP 1-16U how to access 5-4R in a national language B-12R INFO 7-17U INFORMIX-SQL Main menu 1-12U, 2-5U, 1-3R levels in the user-menu structure 5-5R map of hierarchy 1-5R maximum number of options per menu 5-5R modifying ones you created 5-14R naming ones you create 5-16R PERFORM 3-10U REPORT 8-5U, 1-15R selecting options 1-13U SQL 7-5U, 1-13R SYNTAX 7-6U TABLE 2-10U, 1-17R
TABLE, with INFORMIX-OnLine I-2R USER-MENU 1-18R Message file B-18R, C-24R, C-46R Message line of a menu 1-12U Meta-environment variable C-12R Mode insert, in PERFORM 3-17U, 3-13R real, invoking INFORMIX-SQL 1-11U typeover, in PERFORM 3-17U, 3-13R Modify option ALTER TABLE menu 2-24U, 9-7U CREATE TABLE menu 2-11U FORM menu 1-11R REPORT menu 1-15R SQL menu 1-13R USER-MENU menu 1-18R MODIFY REPORT menu Compile option 8-17U Discard-and-exit option 8-17U Save-and-exit option 8-17U MODIFY REPORT screen 8-16U Modifying data, with PERFORM 3-18U MONEY data type definition of 2-17U determining column length 2-17U in forms 3-10R in NLS C-10R Monospace typeface Intro-5U, Intro-5R MONTH( ) function, in ACE reports 4-81R Moving the highlight 1-13U Multiline editor how to invoke 3-14R in PERFORM 3-18U Multiple-table form active table for 5-4U current option 5-14U definition of 5-3U join fields 5-7U lookup join 5-10U master-detail relationship 5-11U orderform 5-8U selecting the detail table 5-12U selecting the master table 5-13U verify join 5-10U
Index
17
N
Naming conventions for a database 2-6U for a table 2-11U for columns 2-13U for report specifications 8-12U User-menu names 5-16R Native Language Support classification of variables C-12R database access restrictions C-7R defined C-2R environment variables listed B-7R, B-39R features supported in Version 6.0 C-9R multiple locales C-47R NCHAR data type C-4R, C-6R, C-10R, C-19R NEED statement, in ACE reports 4-61R Network environment variable SQLRM B-38R SQLRMDIR B-39R New option FORM menu 1-11R REPORT menu 1-15R SQL menu 1-13R Next option, in PERFORM 4-9U, 3-24R NLS database defined C-5R mentioned C-17R performance penalty C-19R NLS environments defined C-5R distinctions between C-6R summary of C-9R NLS. See Native Language Support. Non-NLS database defined C-6R mentioned C-17R US English NLS sorting different from C-23R when preferable to NLS database C-7R Non-NLS environment defined C-5R, C-20R NOUPDATE attribute, in PERFORM 2-44R
NULL values in a column 2-21U in display fields 2-34R Numbers, appearance in reports 8-37U NVARCHAR data type C-4R, C-6R, C-10R, C-19R
O
ON BEGINNING control block, in PERFORM 6-12R ON ENDING control block, in PERFORM 6-12R ON EVERY ROW control block, in ACE reports 8-10U, 8-30U, 4-49R ON LAST ROW control block, in ACE reports 8-11U, 4-51R ONCONFIG environment variable B-36R onconfig file, specifying with ONCONFIG B-36R OnLine database engine Intro-14U programming issues using Intro-14U On-line documentation notes Intro-10R OnLine environment I-1R On-line error messages Intro-6U, Intro-10R Open NLS environment defined C-8R, C-20R mentioned C-5R Operating system using to create a form 2-5R Operators arithmetic, combining with math functions 8-45U arithmetic, in reports 8-36U range, in query 4-10U relational, in query 4-10U value, in query 4-10U Option, how to select 1-13U Order of display fields 2-20R of tables 2-20R orders table in stores demonstration database A-4R OUTPUT FORMAT screen, in PERFORM 4-20U, 3-26R
18
Index
Output option PERFORM 4-17U, 3-25R SQL menu 7-16U, 1-13R OUTPUT section BOTTOM MARGIN statement 4-27R in ACE reports 8-25U, 8-47U LEFT MARGIN statement 4-24R PAGE LENGTH statement 4-28R REPORT TO statement 4-23R RIGHT MARGIN statement 4-25R TOP MARGIN statement 4-26R TOP OF PAGE statement 4-29R Output, displaying for reports 8-47U Output, for a report 8-25U
P
PAGE HEADER control block, in ACE reports 8-10U, 8-28U, 4-52R Page layout 2-12R PAGE LENGTH statement, in ACE reports 8-26U, 4-28R PAGE TRAILER control block, in ACE reports 8-11U, 4-54R PAGENO expression, in ACE reports 4-82R PARAM statement, in ACE reports 4-18R Passing values to a C function 6-18R PATH environment variable B-40R Pathname including in SQLEXEC B-38R specifying with DBPATH B-23R specifying with PATH B-40R PAUSE statement, in ACE reports 4-62R PERFORM accessing from the command line H-9R accessing from the Main menu 3-4R accessing with the menuform form 5-9R active table in 5-4U Add option 3-19R altering a menu structure 5-3R CALL keyword 6-10R calling C functions 6-9R checking data 3-15R checking your data entry 3-15U COLOR attribute 6-20U COMMENTS attribute 6-21U
comparison with SQL 7-7U confirming your entry in a field 3-15U creating a menu 5-8R creating a menu structure 5-3R current list 4-8U Current option 5-14U, 3-20R data types 3-9R DEFAULT attribute 6-23U Detail option 5-11U, 3-21R displaying blobs I-5R DOWNSHIFT attribute 6-22U entering menu data 5-10R entering search criteria 4-10U entering search criteria for query 4-4U example form 6-37R Execute function 3-16U Exit option 3-22R expression 6-10R, 6-14R field editing feature 3-17U field editing keys 3-13R FORM OUTPUT FILE menu 3-25R Help function 3-16U how to access 3-6U how to compile 6-14R how to exit 3-19U how to run 3-3R INCLUDE attribute 6-25U information lines section 3-8U INSTRUCTIONS section 6-9R Interrupt function 3-16U INVISIBLE attribute 6-21U invoking the multiline editor 3-14R library functions 6-22R locating all rows in a table 4-9U Master option 5-11U, 3-23R menu options 3-10U Next option 3-24R ON BEGINNING control block 6-12R ON ENDING control block 6-12R OUTPUT FORMAT menu 3-26R Output option 4-17U, 3-25R positioning the cursor 3-16U, 3-12R Previous option 3-28R query operators and short fields 4-15U Query option 4-4U, 3-29R querying on a range of values 4-13U querying on alternative values 4-15U querying on CHAR fields 4-12U querying on DATE fields 4-11U querying on DATETIME fields 4-11U querying on detail table 5-11U Index 19
querying on FLOAT and SMALLFLOAT fields 4-16U querying on highest value 4-14U querying on INTERVAL fields 4-11U querying on lowest value 4-14U querying on MONEY fields 4-12U querying on number fields 4-11U Remove option 3-32R removing a row 3-19U running operating system commands 3-9R screen for orderform form 5-5U screen form section 3-9U Screen option 3-33R Screen-format option 4-20U searching for a group of rows 4-7U special functions 3-12R storing a row 3-18U Table option 3-34R three sections of screen 3-8U Update option 3-35R updating a row 3-18U UPSHIFT attribute 6-22U using sperform 6-32R using the menuform screen form 5-8R VERIFY attribute 6-27U View option 3-36R PERFORM functions pf_gettype( ) 6-23R pf_getval( ) 6-25R pf_msg( ) 6-31R pf_nxfield( ) 6-29R pf_putval( ) 6-27R PERFORM screen divided into three sections 3-5R entering data 3-9R information lines 3-6R menu options listed 3-7R screen form 3-8R status lines 3-9R PERFORM screen transaction processor accessing from Main menu 3-4R Add option 3-12U, 3-7R adding data with 3-12U, 3-9R CHAR fields in 3-13U, 4-12U comments line 2-33R current list 4-8U, 2-62R Current option 3-7R cursor positioning keys 3-16U, 3-12R data types 3-9R DATE fields in 3-14U, 4-11U 20 Index
DATETIME fields in 3-14U, 4-11U, 4-14U Delete option 3-19U deleting data with 3-19U Detail option 5-11U, 3-7R displaying comments on the screen 6-21U editing keys in 3-17U equal to operator 4-11U Exit option 3-7R exiting from 3-19U, 3-7R explanation of queries in 4-10U field editing 3-13R highest value operator 4-14U, 3-31R how to access 3-6U how to call up 3-3R Information lines in 3-8U, 3-5R, 3-7R insert mode 3-17U, 3-13R INTERVAL fields in 3-15U, 4-11U, 4-14U introduction to 3-5U LOCK statement with 3-19R lowest value operator 4-14U, 3-31R Master option 5-13U, 3-7R menu options 3-10U, 3-7R modifying data with 3-18U MONEY fields in 3-14U, 4-12U multiple-page forms 4-17U Next option 4-9U, 3-7R number fields in 3-13U, 4-11U operating system commands within 3-9R Output option 3-7R pictures in 3-15U Previous option 4-9U, 3-7R Query option 3-7R range operator 4-13U relational operators in 4-11U Remove option 3-7R sample queries 4-16U screen forms with 3-8R Screen option 4-17U, 3-7R search criteria in 4-4U SERIAL fields in 3-13U Status lines in 3-10U, 3-5R, 3-9R Table option 5-4U, 3-7R typeover mode 3-17U, 3-13R Update option 3-18U, 3-7R View option 3-7R what it is 3-5U wildcard characters in 4-12U, 3-30R
Period symbol. See Decimal separator. Peripheral device C-23R pf_gettype( ) function, in PERFORM 6-23R pf_getval( ) function, in PERFORM 6-25R pf_msg( ) function, in PERFORM 6-31R pf_nxfield( ) function, in PERFORM 6-29R pf_putval( ) function, in PERFORM 6-27R PICTURE attribute 3-15U Precedence, rules for environment variables B-6R Pre-Version 6.0 tool C-5R, C-18R Previous option, in PERFORM 4-9U, 3-28R PRINT FILE statement, in ACE reports 4-65R PRINT statement, in ACE reports 4-63R PRINT USING statement 8-37U Printing query results with SQL 7-16U Printing, specifying print program with DBPRINT B-26R Privilege, displaying with the Info option 7-17U Program calling with the User-menu facility 1-25U demonstration database samples 6-33R example, p_ex1.per 6-37R example, stamp.c 6-39R PROGRAM attribute I-11R PROMPT FOR statement, in ACE reports 4-21R PSORT_DBTEMP environment variable B-36R Punctuation symbols Intro-6R
Q
Query by example 4-4U definition of 1-7U, 4-3U examples with PERFORM 4-16U finding all rows in a table 4-9U interactive 7-4U
locating a single row 4-4U moving between screens 4-17U on detail table 5-11U range operators 4-10U relational operators 4-10U saving results in PERFORM 4-17U saving results with SQL 7-16U searching for a group of rows 4-7U searching for a range of values 4-13U searching for alternative values 4-15U searching for an exact match 4-4U searching for columns 1-8U searching for columns within rows 1-8U searching for highest value 4-14U searching for lowest value 4-14U searching for rows 1-8U searching in FLOAT and SMALLFLOAT fields 4-16U sending results to a file 7-16U sending results to a printer 7-16U specifying search criteria for 4-10U structured 1-23U syntax for PERFORM 3-30R using SQL 1-23U using wildcard characters 4-10U, 4-12U value operators 4-10U Query language, definition of 1-23U, 7-4U Query option, in PERFORM 4-4U, 3-29R QUERY screen, in PERFORM 4-5U Querying the database distributed across databases Intro-14U VARCHAR, TEXT and BYTE data I-5R Query-language option, Main menu 1-13R Quotation ( " ) marks single and double Intro-6R Quotes, enclosure of monetary values by C-35R, C-47R Quotes, enclosure of numeric values by C-47R
Index
21
R
Range operators in PERFORM 4-13U, 3-30R with DATETIME fields, in PERFORM 4-14U with INTERVAL fields, in PERFORM 4-14U READ section of report specification 8-24U READ statement 4-33R READ statement, in a report specification 8-24U, 4-33R Real mode invoking INFORMIX-SQL 1-11U Relational DBMS advantages of 1-10U definition of 1-9U Relational operators CHAR fields, in PERFORM 4-12U DATE fields, in PERFORM 4-11U DATETIME fields, in PERFORM 4-11U in PERFORM 4-11U INTERVAL fields, in PERFORM 4-11U MONEY fields, in PERFORM 4-12U numeric fields, in PERFORM 4-11U Relay Module SQLRM environment variable B-38R SQLRMDIR environment variable B-39R Remote databases and tables in forms I-12R Remove option, in PERFORM 3-19U, 3-32R RENAME TABLE statement 9-4U REPORT menu Compile option 8-5U Drop option 8-5U, 1-15R Exit option 1-15R Generate option 8-5U, 8-12U, 1-15R how to use 1-15R Modify option 8-16U, 1-15R New option 8-5U, 1-15R Run option 8-14U, 1-15R summary of options 8-5U Report specification compiling 8-18U correcting 8-18U 22 Index
DATABASE section 8-8U default, compiling 8-13U default, creating 8-12U definition of 8-4U errors in 8-18U FORMAT section 8-10U group functions 8-45U including comments in 8-21U modifying 8-16U OUTPUT section 8-25U READ section 8-24U saving 8-17U SELECT section 8-8U sequence of sections 8-20U summary of sections 8-20U what it contains 8-20U REPORT TO statement, in ACE reports 8-48U, 4-23R Report writer, ACE 8-3U Reports arithmetic operators in 8-36U basic formatting 8-25U calculations in 8-36U compiling 1-15R, 4-5R compiling, linking, and running 6-32R counting rows in 8-43U creating on INFORMIX-OnLine I-8R definition of 8-3U displaying output 8-47U dollar sign in 8-40U editing 1-15R formatting 8-22U group control blocks 8-34U grouping data 8-33U headers 8-27U how numbers appear in 8-37U modifying 8-16U naming conventions 8-12U numbering pages automatically 8-30U organizing the data 8-32U printing a heading 8-28U printing column headings 8-29U printing rows of data 8-30U retrieving data from an ASCII file 8-24U running 8-14U, 1-15R, 4-5R sample report 8-6U sample SELECT statements 8-22U selecting data for 8-22U
steps in creating with ACE 8-4U trailers 8-27U using control blocks to customize 4-41R using fill characters 8-38U writing 1-20U writing to a file 8-48U writing with ACE 8-3U Reserved words F-1R Return value macros, in C program structure 6-21R RIGHT MARGIN statement, in ACE reports 4-25R Row adding rows to a table 1-6U changing the contents with PERFORM 3-18U counting in ACE report 8-43U definition of 1-6U in the stores demonstration database 1-6U locating all in a table 4-9U locating with a query, in PERFORM 4-4U removing with PERFORM 3-19U searching for 1-8U searching for a group, in PERFORM 4-7U storing with PERFORM 3-18U Run option FORM menu 1-11R REPORT menu 1-15R SQL menu 7-12U, 1-13R USER-MENU menu 1-18R RUN REPORT screen 8-14U Running SQL statements 7-12U Run-time program setting DBANSIWARN B-8R
S
sacego and C function calls in ACE 8-49U customizing for ACE 6-32R syntax H-11R using the cace program 6-32R saceprep, compiling report specifications 6-8R, H-10R
Sample form specifications customer A-29R orderform A-30R sample A-32R Sample report specifications, ACE A-34R Save option, SQL menu 1-13R Saving query results with SQL 7-16U Schema editor ADD NUMBER menu 2-15U ADD STARTING NUMBER screen 2-18U ADD TYPE menu 2-18U adding a column to a table 9-6U ALTER TABLE menu 9-6U assigning data types 2-14U CHANGE ANYWAY menu 9-7U changing a table 2-24U correcting mistakes 2-12U creating tables 1-17U defining a column 2-12U definition of 2-12U dropping a column from a table 9-7U exiting 2-22U modifying a column in a table 9-7U naming a table 2-11U Schema, for a table 1-17U, 2-12U Screen CHOOSE 7-15U INFO FOR TABLE 7-17U menu 1-3R menuform fields 5-15R NEW 7-9U PERFORM 3-8U, 5-5U, 3-5R RUN FORM 3-7U, 1-4R sample PERFORM, customer information 2-84R sample PERFORM, order information 2-84R SAVE 7-14U text entry 1-4R USE-EDITOR 7-11U Screen forms active table on 5-4U choosing tables when creating 6-6U choosing the one you want 3-7U creating multiple 3-6U default 6-9U definition of 1-18U, 3-3U definition of multiple-table 5-3U entering data in a table 3-3U features 1-18U Index 23
how to use 3-6U in the demonstration database 3-4U including data from multiple tables 3-5U join fields on 5-7U master-detail relationships on 5-3U maximum number of tables on 3-5U, 6-6U modifying 6-4U naming 6-5U verify joins on 5-10U Screen option ALTER TABLE menu 2-24U CREATE TABLE menu 2-11U in PERFORM 4-17U, 3-33R SCREEN section FORMBUILD 2-7R graphics characters in 2-7R Script menu, how to create 5-24R Search criteria definition of 4-4U in PERFORM 4-4U Select option, DATABASE menu 2-6U, 1-8R SELECT section, of report specification 8-8U SELECT statement distributed across databases Intro-14U in a report specification 8-8U in ACE reports 4-30R SERIAL data type assigning starting number 2-18U definition of 2-16U in forms 3-10R Setting environment variables B-4R sformbld and the .PER extension 6-14R definition of 2-6R syntax H-7R Shaded syntax diagram elements Intro-7R Shared memory parameters, specifying file with ONCONFIG B-36R Shell setting environment variables in a file B-2R specifying with DBREMOTECMD B-27R SKIP statement, in ACE reports 4-66R 24 Index
SKIP TO TOP OF PAGE statement, in ACE reports 4-67R SMALLFLOAT data type definition of 2-16U formatting in form 2-36R in forms 3-10R in NLS C-10R SMALLINT data type definition of 2-16U in forms 3-10R Sorting, PSORT_DBTEMP environment variable B-36R SPACES expression, in ACE reports 4-83R sperform creating a new form 2-6R customizing for PERFORM 6-32R syntax H-9R using the cperf program 6-32R SQL command file 7-14U commenting 7-16U comparison to PERFORM 7-7U correcting errors in statements 7-12U creating a table 7-8U current statements 7-4U definition of 7-4U dropping an index 9-4U editing keys 7-9U editor 7-9U, 7-10U, 7-12U entering statements 7-9U errors, correcting 7-12U formatting statements 7-15U how to access from the Main menu 7-5U how to use 7-3U introduction to 2-4U learning how to use 7-6U long statements 7-10U naming current statements 7-14U options on SQL menu 7-5U renaming a table 9-4U running statements 7-12U saving statements 7-14U separating statements with semicolons 7-16U specifying a system editor 7-10U statements, how to use 1-23U, 7-4U SYNTAX menu 7-6U system editors 7-10U Use-editor option 7-10U
SQL Communications Area (SQLCA) effect of setting DBANSIWARN B-8R SQL menu Choose option 7-5U, 7-14U, 1-13R Drop option 7-5U, 1-13R Exit option 7-5U, 1-13R how to use 1-13R, 1-14R Info option 7-5U, 7-17U, 1-13R introduction to 7-5U Modify option 7-5U, 7-13U, 1-13R New option 7-5U, 7-9U, 1-13R options 7-5U Output option 7-5U, 7-16U, 1-13R Run option 7-5U, 7-12U, 1-13R Save option 7-5U, 7-14U, 1-13R Use-editor option 7-5U, 7-10U, 1-13R SQL statements correcting errors in 7-12U current 7-4U examples 7-16U formatting 7-15U how to enter 7-9U how to run 7-12U how to use 7-4U indicating comments 7-16U modifying 1-13R running 1-13R saving 1-13R selecting 1-13R separating with semicolons 7-16U SQLEXEC environment variable B-38R SQLRM environment variable B-38R SQLRMDIR environment variable B-39R state table in stores demonstration database A-7R Statement segments notational conventions Intro-6R Statements ACE 4-12R ASCII 4-16R BOTTOM MARGIN 4-27R correcting errors 7-12U CREATE TABLE 7-8U current 7-4U definition of 7-4U editing in SQL 7-9U EVERY ROW 4-39R FOR 4-56R how to format 7-15U how to run 7-12U
IF THEN ELSE 4-57R in ACE report specification 8-20U LEFT MARGIN 4-24R LET 4-59R link 2-20R NEED 4-61R PAGE LENGTH 4-28R PARAM 4-18R PAUSE 4-62R PRINT 4-63R PRINT FILE 4-65R PROMPT FOR 4-21R READ 4-33R REPORT TO 4-23R RIGHT MARGIN 4-25R saving in a command file 7-14U SKIP 4-66R SKIP TO TOP OF PAGE 4-67R SQL, definition of 1-23U TOP MARGIN 4-26R TOP OF PAGE 4-29R VARIABLE 4-19R WHILE 4-68R Status displaying with INFORMIX-OnLine I-4R displaying with the Info option 7-17U lines, in PERFORM 3-10U Status lines about 2-33R in PERFORM 3-10U stores demonstration database catalog table A-6R copying A-2R creating A-3R customer table 9-6U, A-4R customer table columns A-4R cust_calls table A-6R data values A-14R described Intro-8U, Intro-11R, A-1R items table A-5R items table columns A-5R join columns 1-9U, A-8R, A-8R to A-14R manufact table A-7R manufact table columns A-7R map of A-8R orders table A-4R orders table columns A-4R report specifications 8-6U, 8-7U restoring the original A-3R Index 25
state table A-7R state table columns A-7R stock table A-5R structure of tables A-3R, A-8R summary of tables 1-5U user-menu design outline 5-7R stty -istrip command C-31R Subdiagram box symbol Intro-7R graphic notation Intro-7R Syntax for ATTRIBUTES section in PERFORM 2-28R for DISPLAY instructions in PERFORM 2-72R for Query option in PERFORM 3-30R sysmenuitems table accessing with PERFORM 5-9R definition of 5-9R sysmenus table accessing with PERFORM 5-9R definition of 5-9R sample data in 5-11R System catalogs syscolauth G-4R syscolumns G-2R sysconstraints G-5R sysdepend G-4R sysindexes G-3R syssynonyms G-4R syssyntable G-6R systabauth G-3R systables G-2R sysusers G-5R sysviews G-5R System catalog, definition of 2-8U System editor 7-11U System files extensions for 2-23U where they are stored 2-23U
T
Table active, in PERFORM 3-5U, 5-4U alias I-13R changing the structure 2-24U, 9-5U connecting through column joins 1-9U
creating a master-detail relationship 2-60R creating and altering with INFORMIX-OnLine I-6R creating through menus 1-17U, 2-11U defining columns for 2-12U definition of 1-5U detail, selecting 5-11U displaying information in 7-17U dropping a column 9-7U finding all rows with Query option 4-9U how to build with the schema editor 2-12U how to create with SQL 7-8U in system catalog 2-8U in the stores demonstration database 1-5U joining columns 1-9U joining tables A-8R listing those in a database 7-17U master, returning to 5-13U modifying a column 9-7U multiple, in a form 5-3U naming 2-11U naming conventions 2-11U order in forms 2-21R removing a row 3-19U removing, using the TABLE menu 9-4U renaming 9-4U schema 1-17U, 2-12U selecting data for a report 8-23U storing a row 3-18U structure in stores demonstration database A-3R sysmenuitems 5-9R sysmenus 5-9R system files that make up a table 2-23U using the schema editor 9-6U TABLE menu Alter option 1-17R Create option 1-17R Drop option 1-17R Exit option 1-17R how to use 1-17R Info option 1-17R schema editor 9-6U summary of options 2-10U with INFORMIX-OnLine I-2R
26
Index
Table option, in PERFORM 5-4U, 3-34R Table schema, how to reproduce 1-17U TABLES section, in form specifications 6-12U, 2-7R Temporary files, specifying directory with DBTEMP B-29R tables, specifying dbspace with DBSPACETEMP B-28R TERM environment variable B-41R TERMCAP environment variable B-41R termcap file and TERMCAP environment variable B-41R color and intensity D-8R description of D-2R graphics characters in screen form D-5R graphics characters in screen forms 2-16R selecting with INFORMIXTERM B-35R Terminal characteristics termcap file D-2R terminfo directory D-18R Terminal handling and TERM environment variable B-41R and TERMCAP environment variable B-41R and TERMINFO environment variable B-42R Terminator, in syntax diagrams Intro-7R terminfo directory and TERMINFO environment variable B-42R description of D-18R graphics characters in screen form D-21R graphics characters in screen forms 2-16R selecting with INFORMIXTERM B-35R TERMINFO environment variable B-42R TEXT data type Intro-14U defining columns I-3R printing in reports I-8R specifying in forms I-9R
Text editor, specifying with DBEDIT B-11R Text entry screen 1-4R Text, how to enter 1-4R Thousands separator 4-87R, B-14R, B-23R, C-31R, C-33R, C-35R, C-40R, C-44R TIME expression, in ACE reports 4-84R TODAY expression, in ACE reports 4-85R TOP MARGIN statement, in ACE reports 8-26U, 4-26R TOP OF PAGE statement, in ACE reports 4-29R Trailing currency symbol 4-87R, B-14R, B-21R, C-33R, C-40R, C-45R Transaction log versus an audit trail 9-9U TRANSACTION menu, in an ANSI-compliant database 9-9U Transactions, definition of 9-8U Typeover mode, in PERFORM 3-17U, 3-13R Typographical conventions Intro-5U, Intro-5R
U
UNIX default print capability in BSD B-5R, B-26R default print capability in System V B-5R, B-26R environment variable setting in BSD and System V B-4R environment variables listed B-7R terminfo library support in System V B-35R viewing environment settings in BSD B-4R viewing environment settings in System V B-4R UNLOAD statement in NLS C-8R, C-11R, C-16R, C-35R, C-40R, C-42R specifying field delimiter with DBDELIMITER B-11R with INFORMIX-OnLine I-6R with VARCHARs and blobs I-6R
Index
27
Update option, in PERFORM 3-18U, 3-35R UPDATE STATISTICS statement and DBUPSPACE environment variable B-29R Uppercase characters typographic convention Intro-5U, Intro-5R UPSHIFT attribute in NLS C-11R in PERFORM 6-22U Use-editor option, SQL menu 7-10U, 1-13R User locale C-2R User locale. See Locale, user locale. User-menu definition of 1-25U designing a menu 5-5R entering menu data 5-10R guidelines for using 1-18R how to access 5-4R layout specifications 5-5R levels of menus 5-5R maximum options per menu 5-5R menu data, entering 5-10R modifying a menu you created 5-14R sample design outline 5-7R steps for entering your own data 5-13R sysmenuitems information 5-9R sysmenus information 5-9R USER-MENU menu Exit option 1-18R how to access from the Main menu 5-4R how to use 1-18R Modify option 1-18R Run option 1-18R USING expression in ACE reports 8-37U, 4-86R in NLS C-11R, C-31R, C-33R, C-39R, C-40R, C-41R, C-43R NLS example C-34R, C-45R Utilities, calling with the User-menu facility 1-25U
V
Values NULL, in a column 2-21U passing to a C function 6-18R querying on a range in PERFORM 4-13U querying on highest in PERFORM 4-14U querying on lowest in PERFORM 4-14U returned to ACE 6-21R returned to PERFORM 6-21R VARCHAR data type defining columns I-3R in NLS C-4R, C-6R, C-10R, C-19R printing in reports I-8R querying with INFORMIX-OnLine I-5R specifying in forms I-8R supported in OnLine Intro-14U transferring with LOAD and UNLOAD I-6R VERIFY attribute, in PERFORM 6-27U Verify joins definition of 6-30U FORMBUILD 2-27R in form specifications 6-30U in multiple-table forms 5-10U in PERFORM 2-27R on a screen form 5-10U View advantages of 9-10U definition of 9-10U View option, in PERFORM 3-36R
W
WEEKDAY( ) function, in ACE reports 4-93R WHILE statement, in ACE reports 4-68R Wildcard characters in PERFORM 4-12U, 3-30R WITHOUT NULL INPUT option 2-34R WORDWRAP expression, in ACE reports 4-94R WORDWRAP keyword I-9R Writing query results to a file with SQL 7-16U
28
Index
X
XPG3 C-2R, C-3R X/Open C-2R X/Open-defined environment variable C-12R, C-13R
Y
YEAR( ) function, in ACE reports 4-95R
Z
Zero, default INTERVAL value 2-9R
Index
29
30
Index
Reader-Response Card
INFORMIX-SQL User Guide, Version 6.0
Dear Reader, At Informix Software, we think documentation is very important. After all, manuals are an integral part of our product line. Because documentation is important, we want to know what you think about our manuals. You can tell us by lling out and returning the ReaderResponse Card. Thanks for your help! 1. Overall, how do you rate this manual? Outstanding 2. Is the manual effective? Is it organized so you can nd things? Is the index adequate? Is the table of contents easy to use? If applicable, do you nd the statement syntax readable? Are topics presented in a useful sequence? Are the examples useful? 3. What did you think of the level of description? Writing quality: Clarity: Level: 4. Very good Very clear Too technical Good Average Just right Average Oversimplied Poor Hard to understand Yes Yes Yes Yes Yes Yes No No No No No No Very good Good Average Poor
When you need to nd information quickly, which part of the documentation do you use? Index: Table of Contents: Quick Reference Card: Chapter summaries: On-line help: Browse through manuals: Often Often Often Often Often Often Sometimes Sometimes Sometimes Sometimes Sometimes Sometimes Rarely Rarely Rarely Rarely Rarely Rarely Never Never Never Never Never Never
5.
How long have you been developing database applications? How many years have you been programming? How many years have you been using databases? How many years have you been using Informix products? 0 0 0 1-3 1-3 1-3 4-5 4-5 4-5 >5 >5 >5
6.
7.
8. 9.
What other Informix products do you use? What is your job title and area of responsibility?
10. Is the format of this manual easy to use? Consider page size, typeface, binding, diagrams, and code examples. 11. Additional comments:
Company Name:
INFORMIX is a registered trademark of Informix Software, Inc. To mail this card, please fold on the dotted line and staple or tape the open end.
Informix Software, Inc. Technical Publications Department 4100 Bohannon Drive Menlo Park, California 94025