Digital PDFs
Documents
Guest
Register
Log In
AA-X025A-TK
September 1983
124 pages
Original
3.7MB
view
download
Document:
Introduction to DATATREIVE-11 Sep83
Order Number:
AA-X025A-TK
Revision:
0
Pages:
124
Original Filename:
AA-X025A-TK_Introduction_to_DATATREIVE-11_Sep83.pdf
OCR Text
Introduction to DATATRIEVE-11 Order No. AA-X025A-TK September 1983 This document introduces you to basic DATATRIEVE-ll commands OPERATING SYSTEM AND VERSION: RSX-IIM RSX-IIM-PLUS RSTS/E SOFTWARE VERSION: DATATRIEVE-ll V3 digital equipment corporation, maynard, massachusetts The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this document. The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license. No responsibility is assumed for the use or reliability of software on equipment that is not supplied by DIGITAL or its affiliated companies. Copyright © 1983 by Digital Equipment Corporation. All Rights Reserved. The postage-paid READER'S COMMENTS form on the last page of this document requests your critical evaluation to assist us in preparing future documentation. The following are trademarks of Digital Equipment Corporation: ~DmDDmD ™ MASSBUS PDP P/OS Professional DEC DECwriter DIBOL UNIBUS VAX VMS VT Rainbow RSTS RSX DECmate DECsystem-10 DECSYSTEM-20 DECUS Work Processor DATATRIEVE-11 DOCUMENTATION MAP Getting Started Learning the Basics Intermediate Applications Advanced Applications r------ Pocket Guide Summary Description Installation Guide I Release Notes t__---- Introduction 1 - - - , . - - - - - Guide to Writing Reports Call Interface Manual iii DATATRIEVE-11 DOCUMENTATION DESCRIPTION GETTING STARTED Summary Description Installation Guide / Release Notes Provides an overview of DATATRIEVE. Describes the installation procedure and Contains a documentation directory, a t--~---t the installation verification procedure. Release Notes contain the latest informaglossary, and the master index. tion about new features, restrictions, and performance guidelines. LEARNING THE BASICS Introduction to DATATRIEVE-11 Interactively guides users through the basic tasks of managing information with DATATRIEVE. INTERMEDIATE APPLICATIONS - - - - -........1 User's Guide Guide to Writing Reports Explains how to define, store, retrieve, modify, and restructure data using f DATATRIEVE. Elaborates on material covered in the Introduction. I Pocket Guide ADVANCED APPLICATIONS iv I I Reference Manual Provides a quick reference guide for expe- ~ Provides full descriptions of the commands, statements. clauses. and other rienced users to the syntax and elements syntax elements that comprise the of DATATRIEVE. DATATRIEVE data management language. Explains how to produce reports based data managed by DATATRIEVE. C scribes the instructions that specify t format and content of a report. Call Interface Manual - Explains how to call DATATRIEVE fn programs in languages such FORTRAN, COBOL, and BASI Describes how to use DATATRIE interactively on another node. Contents Page How to Use This Manual 1 Introduction 1.1 1.2 1.3 2 DATATRIEVE Terminology. Using DATATRIEVE-11. The Sample Domains . . . . Starting DATATRIEVE. . . . . . .. . . . . . . . . . . . . . . Displaying Information About Your DATATRIEVE Environment Accessing Domains . . . . . . . Ending a DATATRIEVE Session . . . . . . . . . . . . . . . . Planning a DATATRIEVE Domain Using ADT . . . . . . . . . . . 3.3 · 3-2 · 3-4 Invoking the .CMD File. · 3-8 Defining Domains Outside ADT . · 3-9 3.2.1 HELP and GUIDE Mode: Quick-Reference Section 4.1 4.2 5 · 2-1 · 2-4 · 2-4 · 2-5 Defining Data with ADT 3.1 3.2 4 · 1-2 · 1-2 · 1-2 Starting and Stopping a DATATRIEVESession 2.1 2.2 2.3 2.4 3 ix Using DATATRIEVE HELP. Using GUIDE Mode. · 4-1 · 4-3 Storing Data 5.1 5.2 5.3 5.4 5.5 5.6 Preparing a Domain for Storing Data . . . . . . . . Using the STORE Statement . . . . . . . . . . . . Preventing a STORE Statement from Taking Effect. Creating a New Record Without Complete Information Storing Two or More Records At a Time. . . . . Storing the Correct Type of Data in New Records . . . · 5-1 · 5-2 · 5-3 · 5-3 · 5-3 · 5-4 v 6 Retrieving Data 6.1 6.2 Displaying All Records in a Domain. Selecting a Group of Records 6.2.1 6.2.2 6.3 6.4 6.5 6.6 6.7 Examples of Displaying Data with the PRINT Statement Sorting Records in Record Streams Displaying Fields from Record Streams Stopping the Display of Records . Using Collections. 6.7.1 6.7.2 6.7.3 6.7.4 6.7.5 6.7.6 6.8 7 Releasing Collections . U sing the FINISH Command 6-11 6-11 6-11 6-U 6-1~ 6-1~ 6-H 6-H 6-1~ 6-H 6-H 6-2( 6-21 Using the SELECT Statement with a Collection. U sing Other Forms of the SELECT Statement. Using the SHOW Command to Identify the Selected Record. Modifying a Selected Record in a Collection . Modifying Fields in Indexed Data Files Modifying All Records in a Collection . Modifying Records in a Record Stream. Modifying Specific Fields in a Record Stream · 7-: · 7-: · 7-, · 7-, · 7-1 · 7-: · 7-~ 7-11 Erasing Data 8.1 U sing the ERASE Statement on Indexed Files. 8.1.1 8.1.2 8.1.3 8.2 vi Showing the Names of Existing Collections Naming an Unnamed Collection. Changing the Content of a Named Collection 6-1~ Modifying Data 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 8 Forming Collections. Displaying the CURRENT Collection Displaying Sorted Records in the CURRENT Collection . Displaying Information About the CURRENT Collection. Making a New CURRENT Collection from an Old One U sing the CURRENT Collection in RSEs Naming a Collection. 6.8.1 6.8.2 6.8.3 6.9 6.10 Specifying the Number of Records in a Record Stream . Limiting Record Streams by Specifying Values · 6-1 · 6-2 · 6-2 · 6-3 · 6-5 · 6-? · 6-9 Erasing a Selected Record . Erasing a Collection of Records Erasing a Record Stream Using the MODIFY Statement on Sequential Files · 8· 8· 8· 8· 8- 9 Writing Simple Reports 9.1 9.2 The General Features of a Report . The Report Specification. 9.2.1 9.2.2 9.2.3 9.3 Multiple-Line Report Names. The Columnsjlage Option Print List Options. · 9-3 · 9-3 · 9-5 Output of Reports . · 9-5 9.3.1 9.3.2 · 9-5 · 9-5 Output to a Line Printer Output to a Disk File Saving Report Specifications. Summary. 9.4 9.5 · 9-1 · 9-2 · 9-6 · 9-6 Glossary Index Figures 1-1 4-1 4-2 The DATATRIEVE Domain. The HELP Screen. . . . The HELP SHOW screen . . · 1-3 · 4-1 · 4-2 Tables 6-1 Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 vii How to Use This Manual This book introduces you to DATATRIEVE-l1. It begins with a brief explanation of information management and the use ofDATATRIEVE. It then guides you through the basic tasks you can perform with DATATRIEVE. Intended Audienc~ The Introduction toDATATRIEVE-ll assumes you can use your terminal to log in to your local computer system and display the contents of your file directory. If you need to review how to do that, consult the user's guide for your operating system. This book addresses people who are unfamiliar with DATATRIEVE-l1. Structure There are nine chapters in this introduction: Chapter 1 Briefly describes information management and lists some basic DATATRIEVE functions Chapter 2 Supplies information about what you have to do to begin using DATATRIEVE, describes some of the basic commands and statements that tell DATATRIEVE what to do, and tells you how to leave DATATRIEVE Chapter 3 Explains how to define information for DATATRIEVE using ADT Chapter 4 Describes the use of Help and Guide Mode to give you online assistance while using DATATRIEVE Chapter 5 Explains how to store information with DATATRIEVE Chapter 6 Describes a variety of ways you can retrieve data ix Chapter 7 Contains information about modifying information you have stored previously Chapter 8 Explains how to erase data Chapter 9 Describes some of the basic features of the DATATRIEVE Report Writer Conventions The following list explains the special symbols used in this book: (Bill This symbol tells you to press the RETURN key on the keyboard of your terminal. This symbol tells you to press the TAB key on the keyboard of your terminal. This symbol tells you to press the CTRL (control) key and a letter key (usually Z or C) at the same time. > The symbol> on a line by itself represents the system prompt. color Text printed in red shows the lines you type while doing the examples. Related Manuals DATATRIEVE-ll Guide to Writing Reports DATATRIEVE-ll User's Guide x Introduction 1 DATATRIEVE-ll is a tool for managing information. Its commands and statements, the words and phrases that make it run, are common English words. This book explains enough of the rules ofDATATRIEVE for you to begin to use it. Information management is a shorthand term for a process that consists of the following tasks: • Setting up some related information (the data you are managing) • Entering information • Retrieving information • Adding new information • Deleting information • Changing information Some of the terminology may be strange to you, but the process itself should be familiar. If you have an address book, for instance, you manage information by: • Picking the style of address book that best meets your needs • Writing the original names and addresses in the book • Finding the address ofa restaurant to try • Adding your new dentist's name and address • Deleting the entry for your previous dentist • Changing a friend's address when the family moves to another city DATATRIEVE allows you to manage large amounts of information in complex ways, but the process of data management remains the same as for your address book. 1-1 1.1 DATATRIEVE Terminology DATATRIEVE uses a vocabulary that may, in part, be unfamiliar to you. Terms you might find unfamiliar are explained when they first appear. With practice and experience, you will become familiar with these terms. To help you, there is a short glossary at the end of this book. In addition, there is a more extensive glossary in the DATATRIEVE-ll Summary Description. 1.2 Using DATATRIEVE-11 This book is designed to help you use the basic commands and statements of DATATRIEVE. This introduction will teach you how to: • Use the Application Design Tool (ADT) to define your own items of information • Ready your data to gain access to it • Print your data • Select items of data that are related in a particular way • Sort your data in various ways • Edit errors in commands and statements • Store new data • Modify existing data • Erase unneeded data • Report your data 1.3 The Sample Domains A record definition defines the organization of information contained in a data file, which is a collection of related records. The domain associates a data file with a record definition. The domain contains no data itself. When you use the domain name, you tell DATATRIEVE to use a particular record definition to interpret the data stored in a specific file. Figure 1-1 illustrates the relationships of the parts of a domain. 1-2 Introduction RECORD DEFINITION - describes data in a data file: 01 CUSTOMER_REC 03 CUSTOMER_NUMBER - contains 5 digits 03 CUSTOMER_NUMBER - contains up to 15 characters What you see when you display the data: z ~ ~ 0 CUSTOMER NUMBER CUSTOMER NAME 101 987 4035 65220 86779 99099 MORRIS SWAYZE FOSTER KELLERMAN JONES ??NAME UNKNOWN "" 0 CJ) cr w ~ ~ 0 f- CJ) ;:) () DATA FILE - contains raw data: . ..J '" 65220KELLERMAN 00101 MORRIS 00987SWAYZE 99099??NAME UNKNOWN 86779JONES 04035FOSTER '--- MK-Q1145--{)O Figure 1-1: The DATATRIEVE Domain When you practice using DATATRIEVE, you can use the four sample domains installed with DATATRIEVE: • FAMILIES • OWNERS • PERSONNEL • YACHTS This book uses the PERSONNEL domain to show how to manage information with DATATRIEVE. You may use any of the domains supplied, or create your own domain so that you have a chance to work with data that is familiar to you. You may find it to be most helpful to practice with a domain you defined for yourself, using the examples in this book as guidelines. If you use the PERSONNEL domain and do all the examples shown in this book, the database will change because you are making real changes when you follow the examples. If you do some but not all of the examples, some of your later results may differ from those printed in the book. Introduction 1-3 Starting and Stopping a DATATRIEVE Session 2 This chapter shows you how to: • StartDATATRIEVE • Show what data is available to you • Get ready to display your data • Stop DATATRIEVE 2.1 Starting OATATRIEVE To start DATATRIEVE, type: DTROOJ DATATRIEVE displays a message resembling the following: DATATRIEVE-ll, DEC query and Report SYsteM Version: V3.00, 10-0CT-83 Type HELP for help DTR> If you do not get this startup banner, type either RUN $DTR or the symbol defined by your system manager to invoke DATATRIEVE. The examples in this book use the sample domains YACHTS, PERSONNEL, OWNERS, and FAMILIES. The first time you use DATATRIEVE you should use the following command to create your own DATATRIEVE dictionary and copy the data files for YACHTS, PERSONNEL, OWNERS, and FAMILIES into your default directory. This ensures that your display of the examples will match the results printed in the book. 2-1 For RSTS/E systems type: DTR> @LB:SETUP.OTROOl For RSX systems type: oT-R > @LB : [ 1 ,Z J SET UP. 0 TROO This command creates a dictionary for you called SAMPLE.DIC, enters the domain and record definitions into your dictionary, and copies the data files into your directory. The command displays the following information: ******************************************************************** Oatatrieve is now setting UP its saMPle definitions and data in your private dictionary SAMPLE.OIC. The data files will be stored in your default directorY. There will be a data files created: YACHT, OWNER, FAMILY and PERSON. ******************************************************************** The commands and definitions scroll on your screen, and the display concludes with the message: ******************************************************************** The Datatrieve saMPle definitions and data have been installed. ******************************************************************** OTR> If you do not know whether you are using a RSTS/E or a RSX system, ask your system manager. In response to the @SETUP.DTRcommand, DATATRIEVE may display a message that SAMPLE.DIC already exists. You can ignore this message. To display the name of your dictionary, type: DTR> SHOW OICTIONARYOOl For RSTS/E systems DAT ATRIEVE responds with a message resembling the following: The current dictionary is SY:[l ,170JSAMPLE.OIC OTR> The message for RSX systems resembles the following: The current dictionary is OBO:[l ,ZJSAMPLE.OIC OTR> 2-2 Starting and Stopping a DATATRIEVE Session You can easily access and display information about your dictionary and its contents whenever you enter DATATRIEVE by executing a command file containing DATATRIEVE statements to make SAMPLE.DIC your default dictionary and display its contents. Follow these steps: 1. Exit from DATATRIEVE by typing: DTR> E}-( I TOO) 2. Create a command file called SAMPLE.CMD and enter the two statements: SET DICTIONARY SAMPLE.DIC SHOW ALL N ow start DATATRIEVE by typing DTR at the system prompt just as you did at the beginning of this chapter. When you see the DTR> prompt again, execute the command file by typing @SAMPLE.CMD. On your terminal DATATRIEVE displays information resembling the following: DTR> @SAMPLE.CMDOO) SET DICTIONARY SAMPLE.DIC SHOW ALL DOfrleli n s: FAMILIES KETCHES OLD_FAMILIES OWNERS OWNERS_SEQUENTIAL PERSONNEL PERSONNEL_SEQ SAILBOATS YACHTS YACHTS_SEQUENTIAL Reco rds: FAMILY_REC OWNER_RECORD PERSONNEL_REC YACHT Procedures: Tables: RIG_TABLE The current dictionary is DBO:[lOOt170]SAMPLE.DIC No established collections No read}' dOfrlains DTR} ._0 ... 000·· f\ 1t.:r~~ SWIt'(2.E \ MK--Qll08-00 Starting and Stopping a DATATRIEVE Session 2-3 2.2 Displaying Information About Your DATATRIEVE Environment To display information about your DATATRIEVE environment, you use variations of the SHOW command. For example, in the command file youjust created, the SHOW ALL command displays the entire contents of your dictionary. You can also display parts of your dictionary contents by using other forms of the SHOW command. To display just the domains you have available, for example, enter: DTR> SHOW DOMAINS(@) DOITlains: FAMILIES KETCHES OWNERS_SEQUENTIAL SAILBOATS YACHTS OLD_FAMILIES OWNERS PERSONNEL PERSONNEL_SEQ YACHTS_SEQUENTIAL DTR> You can also use the SHOW RECORDS command to produce a display of records available to you. The domains, records, and other categories of information about your DATATRIEVE environment that you can display with the SHOW command are called objects. Other forms of the SHOW command are discussed later in this book. 2.3 Accessing Domains To begin working with DATATRIEVE, you must first have access to the domain that you want to use. Preparing the domain for access is known as readying the domain. To ready a domain, type READY followed by the name of the domain. For instance, to ready the PERSONNEL domain, type: DTR> READY PERSONNEL (@) DTR> The DTR> prompt tells you that the PERSONNEL domain is now available to you and that DATATRIEVE is waiting for your next command. You can ready two or more domains at anyone time: DTR> READY YACHTS(@) DTR> READY FAMILIES(@) DTR> To see what domains you have readied, use the SHOW READY command: DTR> SHOW READY(@) Read>' dOlTlains: FAMILIES: RMS SEQUENTIAL. PROTECTED READ YACHTS: RMS INDEXED. PROTECTED READ PERSONNEL: RMS INDEXED. PROTECTED READ DTR> 2-4 Starting and Stopping a DATATRIEVE Session Do not be concerned at present with the phrase ((RMS INDEXED" and ~~PROTECTED READ". Chapter 3 explains indexed files, and the DATATRIEVE-ll Reference Manual discusses ((PROTECTED READ" and other access modes. If you try to ready a domain that is not defined in your dictionary, DATATRIEVE sends you an error message. For example, type: OTR> READY INt.JENTORYillD) "INVENTORY" has not been defined in the dictionan' Execution failed OTR> In the next chapter you will learn more about defining domains. 2.4 Ending a DATATRIEVE Session When you see the DTR> prompt, you can exit from DATATRIEVE in two ways: • Type EXIT and press RETURN OTR> E)O TillD) :> • Press the CTRL and Z keys at the same time. You can use CTRL/Z at any place in the line before you press RETURN. Displays of two examples follow: OTR> "Z > OTR> SHOW REA .'. Z )- Starting and Stopping a DATATRIEVE Session 2-5 Defining Data With ADT 3 This book uses examples from the PERSONNEL domain to teach you some of the uses ofDATATRIEVE. The PERSONNEL domain already exists. However, when you use DATATRIEVE in your work, you create your own domains. The Application Design Tool (ADT) provides a fast way to define a domain and the record definition and data file that go with the domain. ADT prompts you for all necessary information and sends you messages explaining your choices. During a session, ADT prompts for: • The domain name • The data file name • The name of each field • The kind of information in each field, for example characters, numbers, dates, or money • The format of fields containing dates, numbers, or money • The length of fields containing characters or numbers At the end of the ADT session, you can begin to store your data. The Application Design Tool is especially helpful when you are beginning to use DATATRIEVE and want to define your own domains. As you are gaining experience, ADT can help you create the basic definitions. You can later edit these basic definitions to include other features. 3-1 3.1 Planning a DATATRIEVE Domain Before invoking the Application Design Tool, decide what information you want to store. For example, if you are interested in doing some comparison shopping before you buy a new car, you might want to store the following information about each car: • The manufacturer • The model of the car • The model year • The date you visited the show room • The price • The options available You can consider each piece of information as a field in a record. The order in which you enter the fields determines the order DATATRIEVE normally displays the fields on your terminal or prints them in a report. Next, decide the characteristics of each field: • Name You can choose any name you want for each field as long as the name begins with a letter and does' not exceed 31 characters. Possible field names are MAKER, MODEL, YEAR, VISIT_DATE, PRICE and OPTIONS. • QueryName In DATATRIEVE you can use query names as short and easy substitutes for long field names. A query name can replace the complete field name in any DATATRIEVE statement. ADT asks you to supply a query name for any field longer than seven characters. For example, ADT asks you for a query name for the field name VISIT _DATE because VISIT _DATE is longer than seven characters. You could supply the query name VISIT for this field. If you do not wan' to use a query name, press RETURN and continue using ADT. • Data Type Decide what kind of information each field contains: - Character: as many letters, numbers, and other characters as you specify - Date: a choice of four formats - Number: as many digits as you specify, with or without a decimal point - Money: a number preceded by a dollar sign ($) and followed by a decimal point and two digits - Percentage: a number with a percent sign (%) 3-2 Defining Data With ADT The MAKER, MODEL, and OPTIONS fields contain character data. The YEAR field conta,ins a number. The VISIT _DATE field holds date data, and the PRICE field consists of money . • Size The number of letters, numbers, or other characters you need for each field determines the size of the field. For example, the field for options might need 29 characters while the model year only needs two. The number of digits to the left of the decimal determines the size of a field containing money data. Make each field large enough to store the information you want, but not so large that the field wastes memory space. At the beginning of an ADT session, ADT prompts you for the domain name. Choose a name that describes the information you are storing so that the name is meaningful and easy to remember. Since your data is stored on a file, ADT asks you for the name of the file. Again, choose a name that reflects the information you are storing. For example, in the ADT session for comparing cars, you could name the domain AUTOMOBILES and the file AUTO.DAT. At the end of the ADT session, you choose: • The type of data file (sequential or indexed) • The name and attributes of each index key for an indexed file • The name of a command file to contain the definitions A comparison of sequential and indexed files follows: Sequential Files Indexed Files Records are stored in the order you enter them. Records are stored according to the order of the primary field (alphabetically for a field containing characters and numerically for a field containing numbers). Access to information is slow. Access to information is fast. You can change data in any field. You can change data in any field except the primary key field. You cannot erase records from the file. You can erase records from the file. Generally, it is useful to specify an indexed file. If you want an indexed file, ADT asks you for the name of the primary key - the field that determines the order for storing the records in the file. If you want your automobile record in alphabetical order by maker, for example, you should specify the MAKER field as the primary key. Once you have named the primary key, ADTasks you to decide whether you want to allow duplicate values for that field. If MAKER is your primary key, you Defining Data With ADT 3-3 need to allow duplicate values, since one maker (Chevrolet, for instance) has many models of cars. You cannot change the information in a primary key. After you store data for MAKER, you cannot change it unless you erase the whole record and store a new one in its place. In other words, you can have as many Chevrolets as you like listed as makers, but you can never change a Chevrolet to a Ford. ADT also allows you to name alternate index keys. If you plan to perform queries frequently that involve another field, you can name that field as an alternate index key when ADT prompts you for an alternate index key. 3.2 Using ADT The next two sections of this chapter illustrate an ADT session that stores information about cars. A summary of the session follows: • The domain-name: AUTOMOBILES • The file name for the data: AUTO.DAT • The car record fields: Field Name . Query Name Data Type Field Size MAKER MODEL YEAR VISIT_DATE PRICE OPTIONS None None None VISIT None None Character Character Number Date Money Character 10 10 • File type: 2 5 29 Indexed • Field name of the primary key: MAKER • Duplicates for the primary field key: Yes • Alternate index keys: No • The file name for the domain and record definitions: AUTOS You can create this domain yourself by following the example. The most helpful thing you could do for your understanding of the process, however, is to create a domain of your own. Use some type of data familiar to you, and think of the types of reports and queries you want to create using this data. 3-4 Defining Data With ADT ) Design, on paper, a domain that provides the information you need. You can use the following outline as a model: • The domain-name: • The file name for the data: • The record fields: Field Name Query Name Data Type Field Size • File type: • Field name of the primary key: • Duplicates for the primary field key: • Alternate index keys: • The file name for the domain and record definitions: Plunge right in. Do not be afraid of making mistakes, because mistakes are erasable, either just after you make them or later, when the process is complete. During ADT sessions, you can type a question mark (?) at any point where ADT is waiting for a response from you. The message ADT provides is usually adequate to guide you in making the response that is most suitable for what you are trying to do. When you first use ADT, use the question mark frequently. The messages you receive in response to your requests are helpful. You can see as much of the record definition as you have created whenever you want by typing an exclamation point (!). You can exit from ADT at any time by typing CTRL/Z. If you exit before completing the session, everything you have entered simply disappears. Defining Data With ADT 3-5 To start an ADT session, type: DTR> ADT(@) The following session shows the questions that appear on your screen with sample answers. Responses to the first entries are question marks to show you the kind of information that ADT provides when you ask for help. Use the question mark yourself as often as you need: DTR> ADT(@) Do YOU !,.Iant help? (YES or NO) : y~ ADT will help YOU create your DATATRIEVE dOMain and record definitions. The DTR stateMents will be written to the file YOU specify. All answers Must be terMinated by a carria~e return. If YOU need help for any question, type? followed by a return. carria~e If YOU would liKe to see what YOU have defined, enter! followed by a carria~e return. Do }'OU 1"lant detailed questions? (YES or NO) : ?~ Detailed questions are available if YOU are not faMiliar !"d th ADT. Abbreviated questions aSSUMe that YOU already Know ADT concepts and terMinolo~y. Help is available for both types of questions. Do YOU I",ant detailed questions? (YES or NO) : YES~ What do YOU wan t ton alrl e t his dOlT! a in? : ?~ A dOMain is a lo~ically related collection of data which is treated as a unit by DATATRIEVE. You can also thinK of a dOMain as a file. What do }'OU !,.Iant to nalrle this dOMain? : AUTOMOBILES~ What do YOU want to naMe the file where the data for AUTOMOBILES IAlill be? : AUTO.DAT~ What do YOU want to naMe the first field in AUTOMOBILES? What's in MAKER -a DATE a PERCENT MONEY NUMBERS used in arithMetic or ANYTHING ELSE (CHARACTERS)? MAKER~ Enter one of the above : CHARACTERS~ How Irlany characters lon~ is MAKER? : 10~ Are there any Irlore fields in AUTOMOBILES? (YES or NO) : YES~ What do YOU !,.Iant to nalrle the next field in AUTOMOBILES? : MODEL~ What's in MODEL -a DATE a PERCENT MONEY NUMBERS used in arithMetic or ANYTHING ELSE (CHARACTERS)? 3-6 Defining Data With ADT You can specify a field's data type quickly and easily. Simply enter the first letter of the data type you choose. Similarly, you can type either a Y or N in response to questions requiring a yes or no answer. En t era n e o f t h e a b a I) e : COO How ITlany characters long is MODEL? : 1000 Are there an}' ITlore fields in AUTOMOBILES? (YES or NO) : '1'00 What do }'OU !,.Iant to nalTle the next field in AUTOMOBILES? : YEARoo What's in YEAR -a DATE a PERCENT MONEY NUMBERS used in arithMetic or ANYTHING ELSE (CHARACTERS)? Enter one of the above NUMBERSoo How ITI any dig its t o t h e 1 eft 0 f the dec i Mal poi n t? : 200 How ITI an}' dig its t o t her i g h t o f t h e dec i ITI alp 0 in t? : O(@) Day a 1.1 !,.I ant z e r 0 s t o t h e 1 eft top r i n t ass pac e s? : ?oo If YOU do not suppress zeros to the left of the nl.lMbert they will be printed (ex. zip code = 00274 instead of 274). Do }'Ol.l !,.Iant zeros to the left to print as spaces? Y(@) Are the rea n}' ITIO ref i e 1 d sin AUT 0 MOB I L E S ? (Y E S a r NO) : YES(@) What do }'OU !,.Iant to nalTle the next field in AUTOMOBILES? : !.JISIT_DATEoo What is the ~l.Ien' abbreviation for t.JISIT_DATE? : !,JISIToo What's in VISIT_DATE a DATE a PERCENT MONEY NUMBERS used in arithMetic or ANYTHING ELSE (CHARACTERS)? En t era n e o f t h e a b a I) e : DATE(@) ADT prompts you for one of four date formats. You can choose whichever format you prefer. Four date forMats are available: 1 MM/DD/YY 8128/78 2 DD-MMM-YY 28-JUN-78 3 DD-MMM-YYYY 28-JUN-1878 4 DD.MM.YY 28.08.78 En t e r for ITI a t IHtlTI b e r 1 t 2 t 3 tor 4 : 3(8IT) Are there an}' ITlore fields in AUTOMOBILES? (YES or NO) : YES(@) What do}' a 1.1 wan t ton a ITI e the n ext fie 1 din AUT 0 MOB I L E S? : P RIC Eoo What's in PRICE -a DATE a PERCENT MONEY NUMBERS used in arithMetic or ANYTHING ELSE (CHARACTERS)? Enter one of the abol)e MONEYoo H O!,.I ITI any dig its t o t h e 1 eft 0 f the dec i ITI alp a in t? 500 Defining Data With ADT 3-7 ADT formats a money field in this way: • A $ sign before the amount • A decimal point • Either two Os after the decimal point if you type only a dollar amount (for example, 6755) or the cents if you type a dollar and cents amount (for example, 6755.98) Are there an}' ITlore fields in AUTOMOBILES? (YES or NO) : YES(@) What do}' 0 U 1,.,1 ant ton a tTl e the n ext fie 1 din AUT 0 MOB I LES? : 0 P T ION S(@) What's in OPTIONS a DATE a PERCENT MONEY NUMBERS used in arithMetic or ANYTHING ELSE (CHARACTERS)? Enter one of the above: CHARACTERS(@) How irIan}' characters 10n9' is OPTIONS? : 28(@) Are there any ITlore fields in AUTOMOBILES? (YES or NO) : NOm An indexed file can handle certain queries based on a Key field very quicKly. A sequential file is not as fast and does not allow records to be ERASEd. BUTt an indexed file does not allow you to chan9'e the priMarY Key field's data. Do }'OU 1..,1ant }'our data file to be indexed? (YES or NO) : YESm What i s the fie 1 dna tTl e 0 f the p r i ITI a f}' ~~ e y ? : MAKER(@) Do YOU want to allow the field which is the priMarY Key to h a \.1 e d u pI i cat e s? (Y ES 0 r NO) : YES(@) Do}' 0 U 1...1 ant a 1 t ern ate .~ e }' s ? (Y ES 0 r NO) NO(@) What is the naMe of the file where the DATATRIEVE dOITlain and field definitions should 9'0? : AUTOS(@) The DATATRIEVE definitions for your dOMain are located in file AUTOS.CMD; The record len9'th is BB bytes. Do YOU want to define another dOMain? (YES or NO) NO(@) DTR> 3.2.1 Invoking the .CMD File If you completed the above steps, a new file, AUTOS.CMD is placed in your directory. This file contains the definitions of the domain, record, and data file you created during your ADT session. 3-8 Defining Data With ADT You must enter these definitions into your dictionary so you can use them in a DATATRIEVE session. To insert the definitions into your dictionary type @AUTOS. The definitions in AUTOS.CMD scroll on the screen: DTR>@AUTOSOO DEFINE DOMAIN AUTOMOBILES USING AUTOMOBILES-REC ON AUTO.DAT; DEFINE RECORD AUTOMOBILES-REC USING 01 AUTOMOBILES-REC. 15 MAKER PIC IS X(10). 15 MODEL PIC IS X(10). 15 YEAR PIC IS S9(2) EDIT-STRING IS -Z(2). 15 VISIT_DATE USAGE IS DATE EDIT_STRING IS DD-MMM-YYYY QUERY_NAME IS VISIT. 15 PRICE PIC IS S9(5)V99 EDIT_STRING IS $$$t$$$.$$. 15 OPTIONS PIC IS X(29). [Record AUTOMOBILES_REC is BB bytes lon~] DEFINE FILE FOR AUTOMOBILES KEY=MAKER (DUP); DTR> DATATRIEVE inserts the definitions into your current dictionary and creates a data file, AUTO.DAT, in your default directory. When you define your own domains, records, and files, you can place the definitions in separate dictionaries. To create a new dictionary, type: DEFINE DICTIONARY dictionary-name To place the definitions in this dictionary: 1. Type SET DICTIONARY dictionary-name 2. Invoke the command file containing the record definitions 3.3 Defining Domains Outside ADT In this chapter you defined the domain AUTOMOBILES, the record AUTOMOBILES_REC, and the file AUTO.DAT using ADT. You provided the information, and ADT created the definitions for you. You can define domains, records, and files on your own using these commands: • DEFINE DOMAIN • DEFINE RECORD • DEFINE FILE Defining Data With ADT 3-9 These commands give you a number of options not available in ADT. The record for the PERSONNEL domain, used throughout this book, contains some of these additional features. The record definition PERSONNEL_REC is shown below: DTR> SHOW PERSONNEL_REC ru RECORD PERSONNEL_REC USING 01 PERSON. PIC IS 9(5). 05 ID PIC IS }-{(11) 05 EMPLOYEE_STATUS QUERY_NAME IS STATUS QUERY_HEADER IS "STATUS" 1.IALID IF STATUS EQ "TRAINEE" ,IEXPERIENCED"4 QUERY_NAME IS NAME. 05 EMPLOYEE_NAME PIC IS }-{(10) 10 FIRST_NAME QUERY_NAME IS F_NAME. PIC IS }-{(10) 10 LAST_NAME QUERY_NAME IS L_NAME. 05 DEPT PIC IS >no{. 05 START_DATE USAGE IS DATE. PIC IS 9(5) 05 SALARY EDIT_STRING IS $$$,$$$. PIC IS 9(5). 05 SUP_ID As you use this book, you will learn more about this record definition. This book assumes you will use the sample domains or create your own domains with ADT. If at this point you want to use the DEFINE command to create your own domains, you can find further information in theDATATRIEVE-ll User's Guide. You should also know about one or more of the techniques that can help you avoid retyping a long series ofDATATRIEVE statements, either because you made an error or because you want to use the statements again. These techniques are command procedures, DATATRIEVE procedures, the DATATRIEVE editor, and EXTRACT. These are also explained in the DATATRIEVE-ll User's Guide. 3-10 Defining Data With ADT HELP and GUIDE Mode: Quick-Reference Section 4.1 4 Using DATATRIEVE HELP A HELP program is available that can answer many questions you may have as you are using DATATRIEVE. You can call it by typing HELP and pressing RETURN whenever you are at the DTR> prompt. When you request HELP, your screen appears as shown in Figure 4-1. DTR> HELP(@,) Two levels of assistance are available, basic and advanced. To ~et help for the eleMentary DATATRIEVE stateMents, type HELP followed by the naMes of the stateMents for which help is required. To ~et a list of the topics for which help is available, t}'pe HELP HELP To ~et assistance with advanced DATATRIEVE stateMents, type HELP ADVANCED followed by the naMes of the stateMents for which help is required. To ~et a list of the topics for which advanced help is available, type HELP ADVANCED HELP Paired square brackets indicate that the enclosed clause is optional. Capital letters indicate DATATRIEVE Keywords. Words in lower case indicate that a user supplied naMe or value is required. DTR> Figure 4-1: The HELP Screen 4-1 After you become familiar with the HELP program, just type HELP and the name of the topic you are interested in, and the appropriate text appears on the screen. Probably the best way to become familiar with HELP is to type HELP and then simply browse around among the subjects available. In the process, you can also learn about the DATATRIEVE topics you read. Figure 4-2 shows HELP for a sample subject. DTR> HELP SHOWm The SHOW statement is used to display the definitions of domainst recordst procedurest and tables stored in the data dictionary t and information concerning the state of various objects within Datatrieve. The form of the statement is: SHOW obJect-l t obJect-2t obJect-3 ••• 1"lhere each lIobJectll is one of the follol"ling: SETS DOMAINS RECORDS PROCEDURES TABLES COLLECTIONS FIELDS READY CURRENT ALL DICTIONARY SPACE dOITlain-nalTle reco rd-nalTle procedure-nalTle table-nalTle collection-nalTle DTR> Figure 4-2: The HELP SHOW Screen HE.L.R MK-{)1101-OO 4-2 HELP and GUIDE Mode: Quick Reference Section 4.2 Using GUIDE Mode DATATRIEVE offers another type of help in GUIDE mode. GUIDE mode is useful when you arejust learning DATATRIEVE, because it prompts you with a choice of entries that are correct. GUIDE mode works only on DIGITAL's VT family of terminals. If you have a hard-copy terminal and enter a request for GUIDE mode, DATATRIEVE displays an error message on your terminal and returns you to DATATRIEVE command level (indicated by the DTR> prompt). To invoke GUIDE mode, enter: OTR> SET GUIOEru To see how GUIDE mode works, you must use it. You can use GUIDE mode to help y<?u make entries; it completes the typing of keywords if you press the space bar after it has enough letters to uniquely identify the word you are typing. If READY is the only possible entry at a certain point, for example, you can type R and press the space bar. Guide mode completes the word for you. If you type ttRE," ttREA," and so on, it also completes the word as READY. Occasionally the second letter of the command duplicates the first letter of your next word. Suppose you want to ready a domain called EMPLOYEES. If you type ttR" ttE," GUIDE mode sees the HE" as the second letter in READY. You must type ttRE" and then the ttE" of EMPLOYEES. When you enter SET GUIDE and press RETURN, DATATRIEVE clears the terminal screen and prompts you to enter a command or type a question mark (?) for help. If you request help, DATATRIEVE displays all the possible words you can currently use. Throughout, GUIDE mode prompts you for the next part of your entry, including spaces, quotation marks, and carriage returns. Not all options are acceptable in GUIDE mode, but you can find out which ones are at any time by typing a question mark (?), and DATATRIEVE displays all the acceptable alternatives. DATATRIEVE displays an error message if the entry you try is not allowed. You can stop GUIDE mode by typing LEAVE. DATATRIEVE then displays a message on your terminal and returns you to DATATRIEVE command level (indicated by the DTR> prompt): You're on your own now. Good lucK! OTR> Although GUIDE mode is primarily a training tool, you may also find it useful to save keystrokes while typing. Experiment with it, and see the results you get. You can then judge how to use GUIDE mode to your advantage. HELP and GUIDE Mode: Quick Reference Section 4-3 Storing Data 5 This chapter shows you how to add new records to a data file using the STORE statement. 5.1 Preparing a Domain for Storing Data To store new records in a data file, you must ready the domain for WRITE or EXTEND access. With the WRITE command you can store, read, erase, and change records. With the EXTEND command you can only store records. The examples in this chapter use the PERSONNEL domain readied for WRITE access: DTR> READY PERSDNNEL WRITEOO DTR> The DTR> prompt indicates that DATATRIEVE has readied the domain. Verify the type of access by entering: DTR> SHOW READYOO Read}' dorrlains: PERSONNEL: RMS INDEXED, PROTECTED WRITE DTR> The phrase PROTECTED WRITE confirms that you have write access to PERSONNEL. You can now store records with the STORE statement. 5-1 5.2 Using the STORE Statement To add new records to a data file, use the STORE statement. DATATRIEVE immediately prompts you for the value of each elementary field in the new record. To store a new record in the PERSONNEL domain, type: DTR> STORE PERSONNELOO Enter ID: 8742200 Ente r EMPLOYEE_STATUS: E)-<PERIENCEDOO Enter FIRST_NAME: MARTYOO Enter LAST_NAME: KELLEYOO Enter DEPT: T3200 Enter START_DATE: 2G-AUG-188200 En t e r SALARY: 1875000 Enter SUP_ID: 8728800 DTR> Storing a record gives you an opportunity to observe several DATATRIEVE features you have not encounterd before. Since in certain circumstances DATATRIEVE is case sensitive, you should make a habit of using all uppercase letters. Note that DATATRIEVE displays a date in the format you specify in the record definition, not in the format you use when you store the date. In the example above, you entered the date as 26-AUG-1982. You could also have entered it as 082682. In either case, DATATRIEVE displays the date as 26-Aug-1982. Similarly, the record definition determines the format for the SALARY field. You enter the salary without a dollar sign. The record definition determines the form the field takes as output. The PERSONNEL_REC specifies that the dollar sign be printed. If you did the preceding example using your own PERSONNEL database, you actually added this employee to your file. ~ :::L------~ MK~1105_00 5-2 Storing Data 5.3 Preventing a STORE Statement from Taking Effect To prevent the STORE statement from creating a new record, type CTRL/Z at any point before you press RETURN to enter a value in the last field of the record: OTR> STORE PERSONNEL([IT) Enter 10: 07391([IT) En t e r EM PLOYEE_STATUS: TRA I NEE ([IT) Enter FIRST_NAME: CHARLEY([IT) Enter LAST_NAME: ···z Execution terMinated by operator OTR> 5.4 Creating a New Record Without Complete Information You can create a new record, even though all the necessary information is not yet available to you. In the following example, a person has been hired but her starting date, salary, and assignment are unknown. If you enter a SPACE or TAB before pressing RETURN, DATATRIEVE sets the field to blank or zero, depending on the field definition. If you press RETURN without making any entry, DATATRIEVE continues to prompt you until you enter something. OTR> STORE PERSONNEL([IT) Enter 10: ([IT) Enter 10: 123Ll5([IT) En t e r EMPLOYEE_STATUS: TRA I NEE([IT) En t e r FIRST _NAME: HENR I ETTA([IT) En t e r LAST _NAME: M I LLER([IT) Enter DEPT: (!@([IT) Enter START_DATE: @ID([IT) Enter SALARY: (!@([IT) Enter SUP_IO: (!@([IT) OTR> If you did this example, the entry is now included in your PERSONNEL database, with blanks in the DEPT, START _DATE, and SALARY fields, and 00000 in the SUP _ID field. The PERSONNEL_REC record definition sets all these defaults. 5.5 Storing Two or More Records At a Time You can store more than one record at a time by using the REPEAT statement. Type REPEAT, the number of records you want to STORE, and the statement STORE PERSONNEL. DAT ATRIEVE prompts you for the values of each elementary field in each new record: OTR> REPEAT 2 STORE PERSONNEL([IT) Enter 10: 75G39([IT) Enter EMPLOYEE_STATUS: TRAINEE([IT) Enter FIRST_NAME: MIKE([IT) En t e r LAST_NAME: M I LLER([IT) Enter DEPT: TLlLl([IT) Enter START_DATE: G-FEB-1981([IT) (continued on next page) Storing Data 5-3 En t e r Enter Enter Enter Enter Enter Enter Enter En t e r Enter DTR> SALARY: 16750(§] SUP_ID: 00012(§] ID: 756ll0(§] STATUS: TRAINEE(§] FIRST_NAME: BEN(BTI) LAST_NAME: PUTNAM(§] DEPT: Tllll(§] START_DATE: 6-FEB-1881(§] SALARY: 16500(§] SUP_ID: 00012(§] Again, if you did this example, you have added these two employees to your PERSONNEL database. When you are storing more than one record with a STORE command, each single record is stored as you complete the information for it and press the last RETURN before continuing with the next record. If you have requested DATATRIEVE to store a certain number of records and it turns out that you want to enter fewer than you had planned, you can stop the prompting for more entries with CTRL/Z. If you use CTRL/Z to terminate the entry of a record, it affects only that record. 5.6 Storing the Correct Type of Data in New Records The record definition specifies the type of data that you can store in each field of the record. When you create a new record, you must put the correct type of data in each of the fields. For instance, if the record definition requires a number, DATATRIEVE refuses to accept letters. If you try to enter the wrong type of data in a field, DATATRIEVE prompts you again for valid data. Look at the PERSONNEL_REC displayed in section 3.3. To the right of each field name the record contains information describing that field. The PIC IS clause tells you the field's data type and its length. XS indicate character data, and 9s indicate number data. The number in parentheses tells you the length of the field. For example, in the field SUP _ID, the PIC IS clause tells you that you can enter up to five numbers for SUP _ID. Sometimes the length of the field is described as a series of9s or Xs, as in the DEPT field. The three Xs tell you that DEPT contains three characters. A summary of the type of data for the PERSONNEL_REC follows: • EMPLOYEE_STATUS, FIRST _NAME, LAST _NAME, and DEPT accept only character data. • START _DATE accepts only a date. • SALARY and SUP _ID accept only numbers. Sometimes records contain VALID IF clauses. For example, notice the clause VALID IF STATUS EQ ~~TRAINEE", ((EXPERIENCED" in the field EMPLOYEE_STATUS. EQ is an expression meaning equal. The VALID IF clause specifies the choices that you can use for a particular field. In the EMPLOYEE_STATUS field the VALID IF clause tells you to enter either 5-4 Storing Data TRAINEE or EXPERIENCED with capital letters when storing information in that field. DATATRIEVE does not accept any other entry for the field EMPLOYEE_STATUS. The next example shows DATATRIEVE's response to several of these kinds of entries: DTR> STORE PERSONNEL@rn Enter ID: HAROLD@rn Non-di ~it in strin~ IIHAROLDII, i~norin~ character<s) Re-enter ID: 53LJ020@rn Truncation durin~ assi~nMent Re-enter ID: 3LJ020ru En t e r EMPLOYEE_STATUS:' BEG I NNERru Validation error for EMPLOYEE_STATUS Re-enter EMPLOYEE_STATUS: TYROru Validation error for EMPLOYEE_STATUS Re-enter EMPLOYEE_STATUS: TRAINEE@rn Enter FIRST_NAME: hZ Execution terMinated by operator DTR> The next chapter explains how to use the PRINT statement to retrieve data you have stored. Storing Data 5-5 Retrieving Data 6 After you have readied a domain, you can display the data at your terminal. With the PRINT statement, you form a stream of records for display. The record stream you form can be all the records in the domain, or a group of records you select by specifying certain characteristics. 6.1 Displaying All Records in a Domain If the domain does not contain a large number of records, you may want to display all the records it contains. You need type only a READY command and a PRINT statement. The record stream displayed with the following PRINT statement contains all the records in the PERSONNEL domain, including the ones you stored in the previous chapter. (You can also type PRINT ALL PERSONNEL to form the same record stream.) DTR> READY PERSONNELOO) DTR> PRINT PERSONNELOO) ID 00012 00881 02843 12345 12643 32432 34456 38462 38465 38485 48475 48573 48001 48843 75638 75640 78823 83764 STATUS E~<PERIENCED E~<PERIENCED E>~PERIENCED TRAINEE TRAINEE TRAINEE TRAINEE E~< PER I ENCED E><PERIENCED E>~ PER I ENCED E~<PERIENCED TRAINEE E~< PER I ENCED TRAINEE TRAINEE TRAINEE E~< PER I ENCED E~< PER I ENCED FIRST NAME LAST NAME CHARLOTTE FRED CASS HENRIETTA JEFF THOMAS HANK BILL JOANNE DEE GAIL SY DAN BART MIKE BEN LYDIA JIM SP I I.JA HOWL TERRY MILLER TASHKENT SCHWEIK MORRISON SWAY FREIBURG TERRICK CASSIDY KELLER ROBERTS HAMMER MILLER PUTNAM HARRISON MEADER DEPT START DATE TOP F11 D88 12-Sep-72 8-Apr-76 2-Jan-80 C82 F11 T32 T32 E46 D88 E46 T32 C82 D88 T44 T44 F11 T32 4-Apr-81 7-Nol.J-81 1-Mar-82 5-Ma}'-80 20-Feb-80 2-Ma}'-77 2-May-78 2-AU9'-81 7-Jul-78 4-AU9'-81 6-Feb-81 6-Feb-81 18-Jun-78 4-Apr-80 SALARY SUP ID . $75t882 00012 $58t584 00012 $28t808 38485 00000 $32t818 87465 $26t723 00881 $30tOOO 87288 $54tOOO 00012 $23t808 48475 $55t828 00012 $55t407 00012 $31 t546 87288 $41 t385 87465 $26t382 38485 $16t750 00012 $16t500 00012 $40t747 00881 $41 t028 87288 (continued on next page) 6-1 8a375 E}-{PER I ENCED MARY 87288 E}-'PER I ENCED LOUISE 87a22 E}-{PER I ENCED MARTY 87a65 EXPERIENCED ANTHONY 87701 TRAINEE NATHANIEL 88001 E}-{PER I ENCED DAVID 803a2 E}-'PER I ENCED BRUNO 81023 TRAINEE STAN 88028 EXPERIENCED RANDY NALEVO 088 DEPALMA G20 KELLEY T32 IACOBONE C82 CHONTZ Fll LITELLA G20 DONCH I KOt., C82 WITTGEN G20 PODERESIAN C82 3-Jan-76 28-Feb-78 26-AI.l9'-82 2-Jan-73 28-Jan-82 ll-NoIJ-80 8-AI.l9'-78 23-Dec-81 2a-Ma}'-78 $56,8a7 38al $57,588 000: $18,750 8721 $58,a62 000 $2a,502 008! $3a,833 8721 $35,852 87al $25,023 8721 $33,738 87al DTR> DATATRIEVE displays the records in order according to the employees' ID number, which is the primary key. The following section explains limited record streams, which print some but not all of the records. 6.2 Selecting a Group of Records Most often, you want to retrieve only certain records from the domain. DATATRIEVE allows you to select records by using a record selection expression (RSE). The RSE is a phrase that DATATRIEVE uses to form a group of records, called a record stream. When you typed PRINT PERSONNEL in the previous example, you used the simplest form of an RSE, an entire domain. These are also examples ofRSEs: • PRINT FIRST 3 PERSONNEL • PRINT PERSONNEL WITH START_DATE = ~~1-MAR-82" • PRINT PERSONNEL WITH LAST_NAME = ~~HARRISON" • PRINT PERSONNEL WITH SUP _ID = 87289 6.2.1 Specifying the Number of Records in a Record Stream You can limit the number of records in a record stream with the FIRST clause. Suppose you do not want to see all the PERSONNEL records but would like to see the first three. You can limit the record stream with the restriction clause, specifying that you want to display only the FIRST 3 PERSONNEL: DTR> READY PERSONNELm DTR> PRINT FIRST 3 PERSONNELm 10 STATUS FIRST NAME 00012 E}-{PER I ENCED CHARLOTTE 00881 EXPERIENCED FRED 028a3 E}-{PER I ENCED CASS DTR> 6-2 Retrieving Data LAST NAME SPIt.'A HOWL TERRY DEPT START DATE TOP Fll 088 12-Sep-72 8-Apr-76 2-Jan-80 SALARY SU 10 $75,882 000 $58,58a 000 $28,808 38a 6.2.2 Limiting Record Streams by Specifying Values You can also limit a record stream by using a WITH clause. The phrase PERSONNEL WITH SUP _ID = 87289 is a record selection expression (RSE). This phrase forms the record stream by defining specific conditions that individual records must meet to be included. In the following example, the record stream includes only those employees whose supervisor has the ID 87289: OTR> PRINT PERSONNEL WITH SUP_IO = 8728900 IO 3L1L1S8 L18S73 8378L1 87L122 88001 91023 STATUS FIRST NAME HANK SY E~-{PERIENCED JIM E~-{PERIENCED MARTY E}-{ PER I ENCED DAt.! ID TRAINEE STAN TRAINEE TRAINEE LAST NAME DEPT START DATE SALARY SUP ID MORRISON KELLER MEADER KELLEY LITELLA WITTGEN T32 T32 T32 T32 G20 G20 1-Mar-82 2-Au!1-81 L1-Apr-80 28-AU!1-82 11-Nol.l-80 23-Dec-81 $30.000 $31.SLl8 $L11.029 $18.7S0 $3L1.933 $2St023 87289 87289 87289 87289 87289 87289 OTR> The following examples show three different types ofRSE: • Display the records of the first five trainees in the PERSONNEL domain. The RSE is FIRST 5 PERSONNEL WITH STATUS = ((TRAINEE". DATATRIEVE searches through the PERSONNEL file until it has five records that fit the requirements of the RSE. OTR> PRINT FIRST S PERSONNEL WITH STATUS = "TRAINEE"OO ID STATUS 123L1S TRAINEE 128L13 TRAINEE 32L132 TRAINEE 3L1L1S8 TRAINEE L18S73 TRAINEE FIRST NAME LAST NAME DEPT START DATE SALARY SUP ID HENRIETTA JEFF THOMAS HANK SY MILLER TASHKENT SCHWEIK MORRISON KELLER C82 F11 T32 T32 L1-Apr-81 7-Nol.l-81 1-Mar-82 2-AU9'-81 $32.918 $28t723 $30.000 $31.SLl8 00000 87L18S 00891 87289 87289 DTR> • Display the records of employees who started work after I-Jan-1982. The RSE is PERSONNEL WITH START_DATE GREATER_THAN ((1-JAN-1982." DATATRIEVE compares that date with the value of the START _DATE field in every record in the PERSONNEL domain. When it finds a record with a date later than I-Jan-1982, that record becomes part of the record stream. OTR> PRINT PERSONNEL WITH START_DATE GREATER_THAN "1-JAN-1982"00 ID STATUS FIRST NAME 3L14S8 TRAINEE HANK 87422 E~-{PER I ENCED MARTY 87701 TRAINEE NATHANIEL LAST NAME DEPT START DATE MORRISON KELLEY CHONTZ T32 T32 F11 1-Mar-82 28-AU9'-82 28-Jan-82 SALARY SUP ID $30.000 87289 $18t7S0 87289 $24.S02 00891 DTR> Retrieving Data 6-3 • Display the records of employees who earn more than $20,000 but less than $25,000. The RSE is PERSONNEL WITH SALARY BETWEEN 20000 AND 25000. DATATRIEVE again searches through the entire database, selecting all employees whose salaries fall within that range. DTR> PRINT PERSONNEL WITH SALARY BETWEEN 20000 AND 25000ffiTI) ID FIRST NAME STATUS 381185 E}{PER I ENCED JOANNE NATHANIEL 87701 TRAINEE LAST NAME DEPT START DATE FREIBURG CHONTZ Ell8 Fll 20-Feb-80 28-Jan-82 SALARY SUP ID $23,908 a8ll75 $2a,502 00891 DTR> In these examples, GREATER_THAN, =, and BETWEEN control the comparison of the value in a field with the value you supply. They are called relational operators. DATATRIEVE recognizes several relational operators. Table 6-1 lists the ones you can use in DATATRIEVE record selection expressions and shows examples of their use. Notice that you do not need quotation marks around numeric fields that follow the relational operators, but you do need them around character fields and date fields. Table 6-1: Using Relational Operators Specify One of: EQUAL EQ = NOT_EQUAL NE GREATER_THAN GT To Mean: For Example: Equal to STATUS = ~~TRAINEE" Not equal to DEPT NE "T32" Greater than SALARY> 32500 DATE GT "1-Jan-1982" > GREATER_EQUAL GE Greater than or equal to LESS_THAN LT < Less than LESS_EQUAL LE Less than or equal to BETWEEN x AND y BETWEENxy BTxANDy BTxy CONTAINING CONT 6-4 Retrieving Data ID GE 89999 DATE LT "31-Dee-1981" SALARY LT 28000 SALARY LE 30000 Between and incl uding the two SALARY BT 20000 30000 values specified Containing the specified value DEPT CONTAINING "F" STATUS CONT "T" After EQUAL, EQ, or =, you can enter a series of values, using a comma to separate each conditional value from the next one in the series: DTR> PRINT PERSONNEL WITH SUP_ID = 48475 , 3948500 ID STATUS 02943 38465 49843 84375 EHPERIENCED E}{ PER I ENCED TRAINEE E>{ PER I ENCED FIRST NAME LAST NAME DEPT START DATE SALARY SUP ID CASS JOANNE BART MARY TERRY FREIBURG HAMMER NALE1.JO D98 E46 D98 D98 2-Jan-80 20-Feb-80 4-AI.l9'-81 3-Jan-76 $29,908 $23,908 $26,392 $56,847 39485 48475 39485 39485 DTR> This shortcut also works if you type NOT before the EQUAL, EQ, =, or CONTAINING. It does not work, however, for any other specification including NOT_EQUAL. You can form mor-e complex RSEs by using the operators AND, OR, NOT, and BUT. The following example selects only employees who are trainees earning more than $30,000 annually: DTR> PRINT PERSONNEL WITH SALARY ID STATUS 12643 TRAINEE 48573 TRAINEE FIRST NAME JEFF SY :::- 30000 AND STATUS = "TRAINEE"OO LAST NAME DEPT START DATE TASHKENT KELLER C82 T32 4-Apr-81 2-AI.l9'-81 SALARY SUP ID $32,918 87465 $31 ,546 87289 DTR> 6.3 Examples of Displaying Data with the PRINT Statement This section shows you the variety of PRINT statements you can use to form record streams. Try creating RSEs of your own. Retrieving Data 6-5 DTR> PRINT PERSONNEL WITH DEPT = IT32" AND SALARY BT 30000 AND 10 STATUS 34458 TRAINEE 48573 TRAINEE FIRST NAME HANK SY LAST NAME DEPT START DATE MORRISON KELLER T32 T32 1-Mar-82 2-Aug-81 40000~ SALARY SUF 10 $30,000 872E $31 ,548 872E DTR> PRINT PERSONNEL WITH STATUS NE "E){PERIENCED"(BIT) 10 12345 12843 32432 34458 48573 49843 75839 75840 87701 91023 STATUS TRAINEE TRAINEE TRAINEE TRAINEE TRAINEE TRAINEE TRAINEE TRAINEE TRAINEE TRAINEE FIRST NAME LAST NAME DEPT START DATE HENRIETTA JEFF THOMAS HANK SY BART MIKE BEN NATHANIEL STAN MILLER TASHKENT SCHWEIK MORRISON KELLER HAMMER MILLER PUTNAM CHONTZ WITTGEN C82 F11 T32 T32 098 T44 T44 F11 G20 4-Apr-81 7-Nol.l-81 1-Mar-82 2-Aug-81 4-Aug-81 8-Feb-81 8-Feb-81 28-Jan-82 23-Dec-81 SALARY SUF 10 oooe $32,918 874E $28,723 008E $30,000 872E $31 ,548 872E $28,392 394E $18,750 0001 $18,500 0001 $24,502 008S $25,023872E DTR> PRINT PERSONNEL WITH DEPT CONT "T" BUT DEPT NE "TOP"(BIT) 10 STATUS 34458 38482 48573 75839 75840 83784 87422 TRAINEE EXPERIENCED TRAINEE TRAINEE TRAINEE EXPERIENCED EXPERIENCED FIRST NAME HANK BILL SY MIKE BEN JIM MARTY LAST NAME DEPT START DATE SALARY SUF 10 MORRISON SWAY KELLER MILLER PUTNAM MEADER KELLEY T32 T32 T32 T44 T44 T32 T32 1-Mar-82 5-Ma}'-80 2-Aug-81 8-Feb-81 8-Feb-81 4-Apr-80 28-Aug-82 $30,000 $54,000 $31 ,548 $18,750 $18,500 $41 ,029 $18,750 872E 0001 872E 0001 0001 872E 872E DTR> You could have stated these examples in different terms. PERSONNEL WITH STATUS = ((TRAINEE", for example, forms the same group of records as PERSONNEL WITH STATUS NE ((EXPERIENCED". You can form a group of all the records in Department T32 with any of the following: • DEPT = ((T32" • DEPT CONT ((T" BUT DEPT NOT EQUAL ((TOP",((T44" • DEPT NOT EQUAL ((TOP" ,((Fll" ,((D98" ,((C82" ,((E46" ,((G20" ,((T44" • ID = 34456,38462,48573,83764,87422 • LAST _NAME = ((MORRISON" ,((SWAY", ((KELLER", ((MEADER", ((KELLEY" Obviously, the first example is the easiest and most straightforward. The important thing to remember is that many options are available to you when you form record streams. You can specify a record or group of records in many ways, as long as you use correct DATATRIEVE syntax. 6-6 Retrieving Data 6.4 Sorting Records in Record Streams By adding a SORTED BY clause to the end of an RSE, you can tell DATATRIEVE to sort records in the record stream in the order you specify. A field that forms a basis for sorting is called a sort key. For example, you can print the five records of the record stream PERSONNEL WITH DEPT = cCT32" in alphabetical order by LAST _NAME: DTR> PRINT PERSONNEL WITH DEPT 10 STATUS 48573 87422 83784 34458 38482 TRAINEE E}{ PER I ENCED E}{PER I ENCED TRAINEE E}{ PER I ENCED FIRST NAME SY MARTY JIM HANK BILL = IT32" SORTED BY LAST_NAME@TIJ LAST NAME DEPT START DATE SALARY SUP ID KELLER KELLEY MEADER MORRISON SWAY T32 T32 T32 T32 T32 2-AU9'-81 28-AU9'-82 4-Apr-80 1-Mar-82 5-Ma}'-80 $31 ,548 $18,750 $41,028 $30,000 $54,000 87288 87288 87288 87288 00012 DTR> You can sort records by the values in several fields, separating each sort key from the next by a comma. DATATRIEVE sorts the records by the order in which you list the sort keys. Here is a record stream sorted first by DEPT, then by LAST_NAME: DTR> PRINT PERSONNEL SORTED BY DEPT, LAST_NAME@TIJ ID STATUS 12345 TRAINEE 80342 EXPERIENCED 87485 E}{PER I ENCED 88028 E}{PER I ENCED 48001 E}{ PER I ENCED 12843 TRAINEE 48843 TRAINEE 84375 E}{PER I ENCED 38485 E}{ PER I ENCED 02843 E}{PER I ENCED 48475 E}{PER I ENCED 38485 E}{ PER I ENCED 87701 TRAINEE 78823 EHPERIENCED 00881 E}{ PER I ENCED 32432 TRAINEE 87288 E}{PER I ENCED 88001 E}{PER I ENCED 81023 TRAINEE 48573 TRAINEE 87422 E}{ PER I ENCED 83784 EXPERIENCED 34458 TRAINEE 38482 EXPERIENCED 75838 TRAINEE 75840 TRAINEE 00012 E}{PER I ENCED FIRST NAME LAST NAME DEPT START DATE HENRIETTA BRUNO ANTHONY RANDY DAN JEFF BART MARY DEE CASS GAIL JOANNE NATHANIEL LYDIA FRED THOMAS LOUISE DAVID STAN SY MARTY JIM HANK BILL MIKE BEN CHARLOTTE MILLER DoNCH I K0 1•1 IACoBoNE PoDERESIAN ROBERTS TASHKENT HAMMER NALEI)o TERRICK TERRY CASSIDY FREIBURG CHoNTZ HARRISON HOWL SCHWEIK DEPALMA LITELLA WITTGEN KELLER KELLEY MEADER MORRISON SWAY MILLER PUTNAM S P !l.IA C82 C82 C82 C82 C82 D88 D88 D88 D88 E48 E48 F11 F11 F11 F11 G20 G20 G20 T32 T32 T32 T32 T32 T44 T44 TOP 8-AU9'-78 2-Jan-73 24-Ma}'-78 7-Jul-78 4-Apr-81 4-AU9'-81 3-Jan-78 2-May-77 2-Jan-80 2-Ma}'-78 20-Feb-80 28-Jan-82 18-Jl.ln-78 8-Apr-78 7-Nol.J-81 28-Feb-78 11-Nol.J-80 23-Dec-81 2-AU9'-81 28-AI.l9'-82 4-Apr-80 1-Mar-82 5-May-80 8-Feb-81 8-Feb-81 12-Sep-72 SUP SALARY 10 00000 $35,852 87485 $58,482 00012 $33,738 87485 $41 ,385 87485 $32,818 87485 $28,382 38485 $58,847 38485 $55,828 00012 $28,808 38485 $55,407 00012 $23,808 48475 $24,502 00881 $40,747 00881 $58,584 00012 $28,723 00881 $57,588 00012 $34,833 87288 $25,023 87288 $31 ,548 87288 $18,750 87288 $41 ,028 87288 $30,000 87288 $54,000 00012 $18,750 00012 $18,500 00012 $75,882 00012 DTR> Retrieving Data 6-7 In this example DATATRIEVE sorts the records and then lists them in the following order: • Henrietta Miller, the only employee with no department number • All the employees in Department C82 before any employees in any other department • Within Department C82, in alphabetical order by last name DAT ATRIEVE then repeats this sequence for Department D98, E46, and so on. Unless you specify otherwise, DATATRIEVE sorts records by the ascending value of the sort keys you include in the record selection expression. That is, it puts the record with the smallest value first and the largest value last. You can also print records in descending order by typing DESCENDING (or DESC) before a sort key: DTR> PRINT PERSONNEL WITH DEPT = "T32" SORTED BY DESC SALARYlBTIJ ID STATUS 38llG2 837Gll ll8573 3llll5G 871122 E}<PERIENCED E}-{ PER I ENCED TRAINEE TRAINEE E}< PER I ENCED FIRST NAME BILL JIM SY HANK MARTY LAST NAME DEPT START DATE SALARY SUP ID SWAY MEADER KELLER MORRISON KELLEY T32 T32 T32 T32 T32 5-Ma}'-80 ll-Apr-80 2-AU9'-81 1-Mar-82 2G-AU9'-82 $5ll,000 $lll,028 $31,5llG $30,000 $18,750 0001 8728 8728 8728 8728 DTR> The following rules apply to the sort order of your lists: • ASCENDING (or ASC) is the default sort order, sorting from smallest to largest. The default sort order is the order that DATATRIEVE uses to sort records if you do not specify a different order. • Numbers have lower values than letters, so if you do not specify differently, DATATRIEVE first orders the data from 0 to 9, then A to Z. • DESCENDING (or DESC) changes the sort order, sorting from largest to smallest. You can change the sort order as often as you like in any list by specifying ASCENDING or DESCENDING before the name of the field whose order you want to change. When you change the sort order, DATATRIEVE will sort the following items in the new order until you specifically change the order back. 6-8 Retrieving Data DTR> PRINT PERSONNEL SORTED BY DESC DEPT t ASCENDING SALARY(@) ID STATUS 00012 E)< PER I ENCED 75840 TRAINEE 75839 TRAINEE 87422 E}(PER I ENCED 34458 TRAINEE 48573 TRAINEE 83784 E)< PER I ENCED 38482 E)< PER I ENCED 91023 TRAINEE 88001 E)< PER I ENCED 87289 E)<PERIENCED 87701 TRAINEE 32432 TRAINEE 78923 E)< PER I ENCED 00891 E}( PER I ENCED 38485- E}( PER I ENCED 48475 E)<PER I ENCED 49843 TRAINEE 02943 E)< PER I ENCED 39485 E)-( PER I ENCED 84375 E)-( PER I ENCED 12843 TRAINEE 99029 E)-(PER I ENCED 90342 E)<PER I ENCED 49001 E)<PER I ENCED 87485 E)< PER I ENCED 12345 TRAINEE FIRST NAME LAST NAME CHARLOTTE BEN MIKE MARTY HANK SY JIM BILL STAN DA1.JID LOUISE NATHANIEL THOMAS LYDIA FRED JOANNE GAIL BART CASS DEE MARY JEFF RANDY BRUNO DAN ANTHONY HENRIETTA S P II.JA PUTNAM MILLER KELLEY MORRISON KELLER MEADER SWAY WITTGEN LITELLA DEPALMA CHONTZ SCHWEIK HARRISON HOWL FREIBURG CASSIDY HAMMER TERRY TERRICK NALEI.JO TASHKENT PODERESIAN DONCH I K0 1.1 ROBERTS IACOBONE MILLER DEPT START DATE SALARY TOP T44 T44 T32 T32 T32 T32 T32 G20 G20 G20 F11 F11 F11 F11 E48 E48 D98 D98 D98 D98 C82 C82 C82 C82 C82 12-Sep-72 8-Feb-81 8-Feb-81 28-Au9'-82 1-Mar-82 2-Au9'-81 4-Apr-80 5-Ma}'-80 23-Dec-81 11-NoIJ-80 28-Feb-79 28-Jan-82 7-NOIJ-81 19-Jun-79 9-Apr-78 20-Feb-80 2-Ma}'-78 4-Au9'-81 2-Jan-80 2-Ma}'-77 3-Jan-78 4-Apr-81 24-Ma}'-79 9-Au9'-78 7-Jul-79 2-Jan-73 $75t892 $18t500 $18t750 $18t750 $30tOOO $31 t 548 $41 t029 $54tOOO $25t023 $34t933 $57t588 $24t502 $28t723 $40t747 $59t594 $23t908 $55t407 $28t392 $29t908 $55t829 $58t847 $32t918 $33t738 $35t952 $41 t395 $58t482 SUP ID 00012 00012 00012 87289 87289 87289 87289 00012 87289 87289 00012 00891 00891 00891 00012 48475 00012 39485 39485 00012 39485 87485 87485 87485 87485 00012 00000 DTR> 6.5 Displaying Fields from Record Streams You do not have to print all the fields in a record when you form a record stream with an RSE. To limit the number of fields to be printed, type PRINT followed by the names of the fields to be printed, the keyword OF, and the RSE. Separate each field name from the next by a comma. This example shows that you can specify group fields and mix them with elementary fields. NAME is a group field containing the elementary fields FIRST _NAME and LAST _NAME. ID and SUP _ID are elementary fields. DTR> PRINT I D t NAME t SUP_ID OF PERSONNEL WITH DEPT ID 34458 38482 48573 83784 87422 FIRST NAME HANK BILL SY JIM MARTY LAST NAME SUP ID MORRISON SWAY KELLER MEADER KELLEY 87289 00012 87289 87289 87289 "T32"ru DTR> The next example limits the number of records displayed to five by using a restriction clause (FIRST 5). It also uses a sort clause (SORTED BY SALARY). Retrieving Data 6-9 If you specify both a restriction clause and a sort clause in the same RSE, DATATRIEVE sorts the record stream before imposing the restriction. Here DATATRIEVE sorts the PERSONNEL database by salary. It bypasses the employees making less than $25,000 and prints the first five employees making more than that figure. Notice that when you continue your print statement to a second line, DATATRIEVE prompts you with CON>, the continuation prompt. DTR> PRINT NAMEt SALARY OF FIRST 5 PERSONNEL WITH(llij [LooKinf for Boolean expression] CON> SALARY GT 25000 SORTED BY SALARY(llij FIRST NAME LAST NAME SALARY STAN BART THOMAS CASS HANK WITTGEN HAMMER SCHWEIK TERRY MORRISON $25t023 $26t392 $26t723 $29t908 $30tOOO DTR> The phrase H[Looking for Boolean expression]" that appears on the line before the CON> prompt is referring to the kind of expression shown in Table 6-1. A Boolean expression is an expression that DATATRIEVE evaluates to either ~~True" or ~~False." 6.6 Stopping the Display of Records If you do not want to wait for DATATRIEVE to display all the records in a record stream, you can end the display by typing a CTRL/C: DTR> PRINT PERSONNEL(llij LAST NAME DEPT START DATE SALARY 123115 TRAINEE HENRIETTA MILLER 00012 E}< PER I ENCED CHARLOTTE SP!l.IA 00891 E}< PER I ENCED FRED HOWL 029113 E}< PER I ENCED CASS TERRY 126113 TRAINEE JEFF TASHKENT 321132 TRAINEE THOMAS SCHWEIK 3111156 TRAINEE HANK MORRISON 381162 E}< PER I ENCED BILL SWAY 381165 E}< PER I ENCED JOANNE FREIBURG 391185 E}-{ PER I ENCED DEE TERRICK ll8ll75 E}< PER I ENCED GAIL CASSIDY ll8573 TRAINEE SY KELLER "'C Execution te rlTlinated b }' operator TOP F11 D98 C82 Fl1 T32 T32 Ell6 D98 Ell6 T32 12-Sep-72 9-Apr-76 2-Jan-80 ll-Apr-81 7-Nol.l-81 1-Mar-82 5-Ma}'-80 20-Feb-80 2-Ma}'-77 2-Ma}'-78 2-Auf-81 $75t892 $59t59ll $29t908 $32t918 $26t723 $30tOOO $5lltOOO $23t908 $55t829 $55tll07 $31 t5ll6 ID STATUS FIRST NAME DTR> You can enter the CTRL/C at any point. Your terminal displays it as ~~ AC", as shown in the example above. 6-10 Retrieving Data SUI ID OOO( 000: 000: 39ll~ 87ll( 008~ 872~ 000: ll8ll~ 000: 000: 872~ 6.7 Using Collections The record streams you have formed so far have all been temporary. You have to retype the entire PRINT statement to display the same set of records a second time or to sort the record stream in a different way. The FIND statement forms a special type of record stream called a collection. Like a record stream, a collection is a group of records you select from the data available in a domain, such as a collection of all personnel with salaries greater than $40,000. Unlike a record stream, a collection remains available until you release it. Collections differ from record streams in three important ways: • A collection is available to you until you: - Form another collection with the same name with another FIND command - Release the collection with a RELEASE command (See Section 6.9.) - Release the domain from which you formed the collection with a FINISH command (See Section 6.10.) - Exit from DATATRIEVE • You need not retype the RSE if you want to change the sort order of the records or display a subset of the records or fields in the collection. • You can name a collection to keep it from disappearing when you form other collections. 6.7.1 Forming Collections To form a collection, type FIND and a record selection expression (RSE), and press RETURN: OTR> FIND PERSONNEL WITH DEPT = IT32"ru [5 records found] OTR> When you enter the FIND statement, DATATRIEVE looks for records that meet the conditions specified in the RSE. When that search is complete, DATATRIEVE shows how many records it has found but does not display them. 6.7.2 Displaying the CURRENT Collection DATATRIEVE gives the name CURRENT to a collection when you form it. When you form a new collection with another FIND command, the new collection replaces the old one as the CURRENT collection. Retrieving Data 6-11 If you want to see the records in the CURRENT collection, you must use a PRINT statement. Four different PRINT statements display the same records if you have not chosen a particular record in any collection: • PRINT ALL CURRENT • PRINT CURRENT • PRINT ALL • PRINT To see how the first three PRINT statements have identical effects, you can try them all to display the five records in the CURRENT collection you just formed of PERSONNEL from Department T32. The example here shows the output you get: DTR> PRINT ALL CURRENTOO ID STATUS 34458 38482 48573 83784 87422 TRAINEE E)-{ PER I ENCED TRAINEE E)-{PER I ENCED E}-{ PER I ENCED FIRST NAME HANK BILL SY JIM MARTY LAST NAME DEPT START DATE SALARY SUF ID MORRISON SWAY KELLER MEADER KELLEY T32 T32 T32 T32 T32 1-Mar-82 5-Ma}'-80 2-Aug-81 4-Apr-80 28-Aug-82 $30,000 $54,000 $31 ,548 $41 ,029 $18,750 872E 0001 872E 872E 872E DTR> When you enter PRINT ALL, DAT ATRIEVE assumes you are referring to the CURRENT collection. If you have no CURRENT collection and enter PRINT ALL, DATATRIEVE displays this message on your terminal: A current collection has not been established. When you type PRINT by itself, DATATRIEVE first looks to see if you have chosen one particular record with the SELECT statement. If you have, DATATRIEVE prints it. If you have not, DATATRIEVE first displays a message on your terminal and then displays all the records in the CURRENT collection: DTR> PRINTOO No record selected, printing whole collection ID STATUS 34458 38482 48573 83784 87422 TRAINEE E)-{ PER I ENCED TRAINEE E}-{ PER I ENCED E)-{ PER I ENCED FIRST NAME HANK BILL SY JIM MARTY LAST NAME DEPT START DATE SALARY SUP ID MORRISON SWAY KELLER MEADER KELLEY T32 T32 T32 T32 T32 1-Mar-82 5-Ma}'-80 2-Aug-81 4-Apr-80 28-Aug-82 $30,000 $54,000 $31 ,548 $41 ,029 $18,750 8728 0001 8728 8728 8728 DTR> See Section 7.1 for information on the SELECT statement. 6-12 Retrieving Data 6.7.3 Displaying Sorted Records in the CURRENT Collection The sort order specified in the PRINT statement affects only the record stream formed by the PRINT statement. It has no effect on the CURRENT collection, which always remains the same. To see that the original order of the CURRENT collection does not change, use the following FIND statement to form a collection of employees reporting to the supervisor with ID Number 00012. DTR> FIND PERSONNEL WITH SUP_ID [8 reeo rds found] DTR> PRINT CURRENTru ID STATUS 00012 00881 38482 38485 48475 75838 75840 87288 87485 E}-{ PER I ENCED E}-( PER I ENCED E~<PER I ENCED E~<PER I ENCED FIRST NAME CHARLOTTE FRED BILL DEE E~<PERIENCED GAIL TRAINEE MIKE TRAINEE BEN E}-( PER I ENCED LOUISE E}-{ PER I ENCED ANTHONY 00012ru LAST NAME DEPT START DATE SALARY SUP ID SP I I.JA HOWL SWAY TERRICK CASSIDY MILLER PUTNAM DEPALMA IACOBONE TOP F11 T32 D88 E48 T44 T44 G20 C82 12-Sep-72 8-Apr-78 5-Ma}'-80 2-Ma}'-77 2-Ma}'-78 8-Feb-81 8-Feb-81 28-Feb-78 2-Jan-73 $75t882 $58t584 $54tOOO $55t828 $55t407 $18t750 $18t500 $57t588 $58t482 00012 00012 00012 00012 00012 00012 00012 00012 00012 Notice that the collection is made up of records sorted by ID. Now sort the collection and print it in alphabetical order. DTR> PRINT CURRENT SORTED BY LAST_NAMEru ID FIRST NAME LAST NAME DEPT START DATE SALARY SUP ID GAIL LOUISE FRED ANTHONY MIKE BEN CHARLOTTE BILL DEE CASSIDY DEPALMA HOWL IACOBONE MILLER PUTNAM SP II.JA SWAY TERRICK E48 G20 F11 C82 T44 T4Ll TOP T32 D88 2-Ma}'-78 28-Feb-78 8-Apr-78 2-Jan-73 8-Feb-81 8-Feb-81 12-Sep-72 5-Ma}'-80 2-Ma}'-77 $55t407 $57t588 $58t584 $58t482 $18t750 $18t500 $75t882 $54tOOO $55t828 00012 00012 00012 00012 00012 00012 00012 00012 00012 STATUS 48475 E~< PER I ENCED 87288 E~< PER I ENCED 00881 E~< PER I ENCED 87485 E~< PER I ENCED 75838 TRAINEE 75840 TRAINEE 00012 E~<PERIENCED 38482 E}< PER I ENCED 38485 E~< PER I ENCED Finally, to see that the collection itself has not been changed, have DATATRIEVE print the collection again without sorting it. DTR> PRINT CURRENTru ID STATUS FIRST NAME 00012 E}-{ PER I ENCED CHARLOTTE 00881 E}-{ PER I ENCED FRED 38482 E~< PER I ENCED BILL 39485 E}-( PER I ENCED DEE 48475 E~< PER I ENCED GAIL LAST NAME DEPT START DATE SALARY SUP ID SP II.JA HOWL SWAY TERRICK CASSIDY TOP F11 T32 D98 E48 12-Sep-72 8-Apr-78 5-Ma}'-80 2-Ma}'-77 2-Ma}'-78 $75t882 $58t584 $54tOOO $55t829 $55t407 00012 00012 00012 00012 00012 (continued on next page) Retrieving Data 6-13 75638 TRAINEE 756ao TRAINEE 87288 E}< PER I ENCED 87a65 E}-{ PER I ENCED MIKE BEN LOUISE ANTHONY MILLER PUTNAM DEPALMA IACOBONE Taa Taa G20 C82 6-Feb-81 6-Feb-81 28-Feb-78 2-Jan -73' $16,750 OOOJ $16,500 OOOJ $57,588 OOOJ $58,a62 OOOJ DTR> You can specify a sort order with the FIND statement just as you do with the PRINT statement. As for collections that do not specify a sort order, a PRINT statement specifying a sort order has no effect on the order in the collection itself. 6.7.4 Displaying Information About the CURRENT Collection You can use the SHOW command to display information about the CURRENT collection. Type SHOW CURRENT and press RETURN: DTR> SHOW CURRENT(@) Collection CURRENT Domain: PERSONNEL Number of Records: 8 No Selected Record DTR> This display tells you that the CURRENT collection comes from the PERSONNEL domain, contains nine records, and has no selected record. Chapter 7 explains selected records. 6.7.5 Making a New CURRENT Collection from an Old One You can form a series of CURRENT collections, each based on the previous one. For example, you can keep changing the limiting value of the same field: DTR> FIND PERSONNEL WITH SALARY :> 3000000 [16 records found] DTR> FIND CURRENT WITH SALARY> aOOOO(@) [11 records found] DTR> F I NO CURRENT ~l I TH SALARY > 5000000 [8 records found] DTR> FIND CURRENT WITH SALARY 6000000 [1 record found] DTR> PRINT ALL(@) 10 STATUS FIRST NAME 00012 EXPERIENCED CHARLOTTE LAST NAME SPIVA DEPT START DATE TOP 12-Sep-72 SUP SALARY 10 $75,882 0001 DTR> You can also use a different field each time to reduce the number of records in the CURRENT collection: DTR> FIND PERSONNEL WITH SUP_ID [8 records found] 0001200 (continued on next page) 6-14 Retrieving Data DTR> FIND CURRENT WITH SALARY > 57500ru [4 records found] DTR> FIND CURRENT WITH START_DATE GT "1-JAN-1978"ru [1 record found] DTR> PRINT CURRENT@] FIRST NAME LAST NAME DEPT START DATE 87289 EXPERIENCED LOUISE DEPALMA G20 28-Feb-79 ID STATUS SUP ID SALARY $57,598 00012 DTR> 6.7.6 Using the CURRENT Collection in RSEs When you want to refer to the CURRENT collection, you can type CURRENT instead of the original RSE you entered to form the collection. The following sequence forms a collection, prints it, sorts the records into a new order, and prints the first five in that order: DTR> FIND PERSONNEL WITH SUP_ID [9 records found] DTR> PRINT ALL@] 00012@] ID STATUS FIRST NAME LAST NAME 00012 00891 38482 39485 48475 75839 75840 87289 87485 EXPERIENCED EXPERIENCED EXPERIENCED EXPERIENCED EXPERIENCED TRAINEE TRAINEE EXPERIENCED EXPERIENCED CHARLOTTE FRED BILL DEE GAIL MIKE BEN LOUISE ANTHONY SP II,JA HOWL SWAY TERRICK CASSIDY MILLER PUTNAM DEPALMA IACOBONE DEPT TOP Fll T32 D98 E48 T44 Ta4 G20 C82 START DATE SALARY SUP ID 12-Sep-72 9-Apr-78 5-Ma}'-80 2-Ma}'-77 2-Ma}'-78 8-Feb-81 8-Feb-81 28-Feb-79 2-Jan-73 $75,892 $59,594 $54,000 $55,829 $55,407 $18,750 $18,500 $57,598 $58,482 00012 00012 00012 00012 00012 00012 00012 00012 00012 DTR> PRINT FIRST 5 CURRENT SORTED BY DESC SALARY@] ID STATUS FIRST NAME LAST NAME 00012 00891 87485 87289 39485 EXPERIENCED EXPERIENCED EXPERIENCED EXPERIENCED EXPERIENCED CHARLOTTE FRED ANTHONY LOUISE DEE HOWL IACOBONE DEPALMA TERRICK S P !l.JA DEPT START DATE SALARY SUP ID TOP Fll C82 G20 D98 12-Sep-72 9-Apr-78 2-Jan-73 28-Feb-79 2-Ma}'-77 $75,892 $59,594 $58,482 $57,598 $55,829 00012 00012 00012 00012 00012 DTR} After this sequence of statements, the CURRENT collection remains the same. It contains all the original records in their original order. 6.8 Naming a Collection So far, you have created only one collection at anyone time - the CURRENT collection. Each time you formed a new CURRENT collection, the old one disappeared. Retrieving Data 6-15 You can create more than one collection by giving each collection a name when you form it with the FIND statement. For example, you can form a collection of trainees and name the collection TYROS: DTR> FIND TYROS IN PERSONNEL WITH STATUS = "TRAINEE"OO) [10 records found] DTR> This new CURRENT collection has the name TYROS. You can use any name you like. To confirm that the CURRENT collection has the name you gave it, use the SHOW COLLECTIONS command. DTR> SHOW COLLECTIONSOO) Collections: TYROS (also CURRENT) DTR> You can now use the collection name TYROS in other DATATRIEVE commands and statements. When you form a new CURRENT collection, the TYROS collection remains. It does not disappear as an unnamed collection would have. The name CURRENT becomes attached to the newly formed collection. You can still use TYROS to refer to the original collection in other DA TATRIEVE commands and statements. The SHOW CURRENT command does not refer to TYROS any longer, but the SHOW TYROS command shows that it is still available: DTR> FIND E>~PERTS IN PERSONNEL WITH STATUS = IEi-{PERIENCED"(8TIj [17 records found] DTR> SHOW CURRENT(@) Collection CURRENT DOMain: PERSONNEL NUfTlber of Records: 17 No Selected Record (continued on next page) 6-16 Retrieving Data OTR> SHOW TYROSOO Collection TYROS OOITla in: PERSONNEL NUITlb e r of Records: 10 No Selected Record OTR> PRINT FIRST 3 CURRENTOO 10 STATUS FIRST NAME 00012 E){PER I ENCEO CHARLOTTE 00891 E){PERIENCEO FRED 02943 E)-( PER I ENCEO CASS LAST NAME S P !l.JA HOWL TERRY DEPT START DATE TOP F11 098 12-Sep-72 9-Apr-76 2-Jan-80 SALARY SUP 10 $75t892 00012 $59t594 00012 $29t908 39485 OTR> PRINT FIRST 3 TYROSOO 10 STATUS 12345 TRAINEE 12643 TRAINEE 32432 TRAINEE FIRST NAME LAST NAME DEPT START DATE HENRIETTA JEFF THOMAS MILLER TASHKENT SCHWEIK C82 F11 4-Apr-81 7-No!.l-81 SALARY SUP 10 00000 $32t918 87465 $26t723 00891 OTR> 6.8.1 Showing the Names of Existing Collections You can have as many named collections as you want. To see the names of all the collections you have, use the SHOW COLLECTIONS command: OTR> SHOW COLLECTIONSOO Collections: EXPERTS (also CURRENT) TYROS OTR> In response to the SHOW COLLECTIONS command, DATATRIEVE lists the most recently formed collection first and the oldest of the existing collections last. If the CURRENT collection has a name, DATATRIEVE displays a note beside the name of that collection to show that it is also the CURRENT collection. If the CURRENT collection is unnamed, DATATRIEVE displays the name CURRENT on the list of collections: OTR> FIND PERSONNEL WITH DEPT [5 records found] OTR> SHOW COLLECTIONSOO Collections: CURRENT E){ PERTS TYROS IC82"lliITJ (continued on next page) Retrieving Data 6-17 DTR> PRINT FIRST 2 CURRENT(@:) ID STATUS FIRST NAME 12843 TRAINEE JEFF 48001 E}-{PER I ENCED DAN LAST NAME DEPT START DATE TASHKENT ROBERTS C82 C82 4-Apr-81 7-Jul-78 SALARY SUF ID $32,818 874e $41 ,385 874e DTR> To display records in a named collection that is not the CURRENT collection, you must use the collection name in the RSE of a PRINT statement: DTR> PRINT FIRST 2 TYROSm ID STATUS 12345 TRAINEE 12843 TRAINEE FIRST NAME LAST NAME DEPT START DATE HENRIETTA JEFF MILLER TASHKENT C82 4-Apr-81 LAST NAME DEPT START DATE TOP F11 12-Sep-72 8-Apr-78 SALARY SUF ID OOOC $32,818 874e DTR> PRINT FIRST 2 ENPERTS(@:) ID STATUS FIRST NAME 00012 E}-{PER I ENCED CHARLOTTE 00881 E}-{PER I ENCED FRED S P Il.IA HOWL SALARY SUF ID $75,882 0001 $58,584 0001 DTR> When you have access to more than one collection, PRINT ALL always causes DATATRIEVE to display the records in the CURRENT collection. If you use PRINT ALL TYROS, or the name of any other collection you have formed, DATATRIEVE displays all the records in the collection you name. 6.8.2 Naming an Unnamed Collection If you have not named your CURRENT collection and then decide you want to keep it, you can name it by using the FIND command: DTR> FIND DEPT_C82 IN CURRENTm [5 records found] DTR> SHOW COLLECTIONSm Collections: DEPT_C82 (also CURRENT) E}-{PERTS TYROS DTR> This command does not actually rename the CURRENT collection. It forms a . new CURRENT collection named DEPT _C82 that contains the same records as the previous CURRENT collection, which no longer exists. 6-18 Retrieving Data You can also change the name of a named collection. The newly formed collection does not replace the older one. The new one goes, instead, to the top of the list of existing collections. The collection now has two names, C82 and CURRENT. OTR> FINO C82 IN DEPT_C82®] [5 records found] DTR > SHO~J COLLECT IONS®] Collections: C82 (also CURRENT) DEPT_C82 E){ PERTS TYROS OTR> You can use this same method to impose new limits on a collection without having to retype the original RSE. The collection TYROS consists of all the employees who are trainees. You can form a new collection called NEW_TRAINEES by including only those TYROS that started after I-Jan-1982. NEW_TRAINEES becomes the CURRENT collection, but you still have access to TYROS: OTR> FIND NEW_TRAINEES IN TYROS WITH START_DATE GT "1-Jan-1882"®] [2 records found] DTR > SHO~J COLLECT IONS®] Collections: NEW_TRAINEES (also CURRENT) C82 DEP7_C82 E>~ PERTS TYROS DTR> 6.8.3 Changing the Content of a Named Collection To change the content of a named collection, use the same name in a FIND command with new conditions specified in the RSE. When you use the name of an existing collection, DATATRIEVE releases the old collection with the same name and makes the new one the CURRENT collection: DTR > FIN D NEW _ TRAI NEE S I t· ·J T\' R0 ~3 ~l I TH S TAR T_ DATE GT "1 - J UL - 1 8 8 1 "®] [6 records found] DTR > SHO~l COLLEC T I ON S®] Collections: NEW_TRAINEES (also CURRENT) C82 DEPT_C82 E>~PERTS TYROS DTR> FIND ~~E~LTRAINEES I~··l TYROS l·lITH START_DATE GT "1-JAN-1882"®] [2 records found] DTR> SHOW COLLECTIO~~S®] Collections: NEW_TRAINEES (also CURRENT) C82 DEPT_C82 E>~PERTS TYROS (continued on next page) Retrieving Data 6-19 DTR> PR I NT NEilL TRA I NEES(BD) ID STATUS 3aa56 TRAINEE 87701 TRAINEE FIRST NAME LAST NAME DEPT START DATE HANK NATHANIEL MORRISON CHONTZ T32 F11 1-Mar-82 28-Jan-82 SUF SALARY ID $30,000 872E $2a,502 008~ DTR> 6.9 Releasing Collections When you no longer need to use a collection, you can release it with the RELEASE command. Releasing a collection does not affect the data file. You can verify the release of a collection with the SHOW COLLECTIONS command: 'DTR> RELEASE C82(BD) DTR> SHOW COLLECTIONS(BD) Collections: NEW_TRAINEES (also CURRENT) DEPT_C82 E}-{PERTS TYROS DTR> RELEASE CURRENT(BD) DTR> SHOW COLLECTIONS(BD) Collections: DEPT_C82 (also CURRENT) E}-{PERTS TYROS DTR> RELEASE TYROS(BD) DTR> SHOW COLLECTIONS(BD) Collections: DEPT_C82 (also CURRENT) E}-{PERTS DTR> RELEASE E}-{PERTS, DEPT _C82(BD) DTR> SHOW COLLECTIONS(BD) No established collections DTR> RELEASE(BD) LooKing for Dictionary NaMe CON> ,', Z DTR> From this sequence, you can see several rules for releasing collections: • You can release collections in ,any order. • You can release more than one collection at a time . • If you release the CURRENT collection, the next most recently formed collection becomes the new CURRENT collection. 6-20 Retrieving Data • If you release a named current collection, you can refer to it in the RELEASE command by its name or by CURRENT. • If you use the RELEASE command without specifying a collection or collections, DATATRIEVE prompts you for a collection with the CON> prompt. 6.10 Using the FINISH Command You can use the FINISH command to release all your collections. The FINISH command also ends your access to all your readied domains, or to specific domains. To show the use of the FINISH command, the following example forms three collections from the PERSONNEL domain. The SHOW COLLECTIONS command lists the three collections, and the SHOW READY command lists PERSONNEL as a readied domain. After the FINISH command, the SHOW COLLECTIONS and SHOW READY commands show the effect of finishing the domain: DTR> FIND TYROS IN PERSONNEL WITH STATUS = ITRAINEE"m [10 records found] DTR> FIND E><PERTS IN PERSONNEL WITH STATUS = "E><PERIENCED" m [17 records found] DTR> FIND C82 IN PERSONNEL WITH DEPT = IC82"m [5 records found] DTR> SHOW COLLECTIONSm Collections: C82 (also CURRENT) E}<PERTS TYROS DTR> SHOW READym Read}' dOfrlains: PERSONNEL: RMS INDEXEDt PROTECTED READ DTR> FINISHm DTR> SHOW COLLECTIONSm No established collections DTR> SHOW READym No read}' dOfrlains DTR> If you have more than one domain readied, you can finish specific domains by including the domain names in the FINISH command. To finish only the PERSONNEL domain, you type this command: DTR> F I·N I SH PERSONNELm This command releases the PERSONNEL domain and any collections associated with it, but no others. Retrieving Data 6-21 Modifying Data 7 When information changes or you have made errors in entering data, you need a way to enter the corrected information. In DATATRIEVE, you can make changes to existing records with the MODIFY statement. You need to specify which records you want to change by isolating them either in a collection or in a record stream. This chapter discusses the use of both collections and record streams for modifying data. 7.1 Using the SELECT Statement with a Collection To modify one or more records, you can form a collection and use the SELECT statement to choose a record you want to change. The following examples show how the SELECT statement chooses one record in a collection. Ready the PERSONNEL domain and form a collection with the FIND statement. Display the collection on your terminal by using the PRINT ALL statement: DTR> READY PERSONNEL MODIFYQIDj DTR> FIND PERSONNEL WITH SUP_ID = 39Ll85QIDj [3 records found] DTR> PRINT ALLQIDj 10 STATUS FIRST NAME 029Ll3 E}-{PER I EN CEO CASS Ll88Ll3 TRAINEE BART SLl375 E}·' PER I ENCED MARY LAST NAME DEPT START DATE TERRY HAMMER NALEt.JO 098 088 098 2-Jan-80 Ll-Aug-81 3-Jan-76 SALARY SUP 10 $29,808 38Ll85 $26,382 38Ll85 $56,SLl7 38LlS5 DTR> When you use the SELECT statement, DATATRIEVE marks one record in the target collection. If you have not yet selected a record in a collection and do not specify a particular record with the SELECT statement, DATATRIEVE selects the first record as the target record. If you are at any other place in the collection, DATATRIEVE selects the next record. 7-1 To display the first record in the collection, enter: DTR> SELECT(@:) DTR> PRINT(@:) ID STATUS FIRST NAME 029Q3 EXPERIENCED CASS LAST NAME TERRY DEPT START DATE D9S 2-Jan-SO SALARY SUI ID $29 t90S 39Qt DTR> When you enter another SELECT statement, DATATRIEVE then marks the next record in the collection as the target record: DTR> SELECT(@:) DTR> PRINT(@:) ID STATUS Q9SQ3 TRAINEE FIRST NAME BART LAST NAME DEPT START DATE HAMMER D9S Q-Aug-Sl LAST NAME DEPT START DATE NALEI.JO D9S 3-Jan-76 SALARY SUI ID $26t392 39Qt DTR> SELECT(@:) DTR> PRINT(@:) ID STATUS FIRST NAME SQ375 E)-( PER I ENCED MARY SALARY SUI ID $56tSQ7 39QI DTR> You can continue selecting records in an entire collection in this way, no matter how many records are present. You can also display only part of the information in the selected record: DTR> PRINT IDt NAMEt START_DATE(@:) ID FIRST NAME SQ375 MARY LAST NAME START DATE NALEI.JO 3-Jan-76 DTI'i'> 7.2 Using Other Forms of the SELECT Statement When you have a collection, you can choose any single record in the collection with some form of the SELECT statement: • SELECT FIRST - Selects the first record in the collection. • SELECT LAST - Selects the last record in the collection. 7-2 Modifying Data • SELECT or SELECT NEXT - Selects the next record in the collection. If you have not selected any record, SELECT NEXT picks the first record. If there is no next record because you are at the end of the collection, DATATRIEVE displays the following error message: Record number out of Execution failed ran~e for collection • SELECT n - Selects the record in the collection indicated by the number n, which must be between 1 and the number of the last record in the collection. SELECT 5, for example, selects the fifth record in the collection. It does not select five records. If you specify a number greater than the number of records in the collection, DATATRIEVE displays the following error message: Record number out of Execution failed ran~e for collection The following series of SELECT and PRINT statements shows how the various forms of the SELECT statement work. The examples also show how to include two or more DATATRIEVE statements on a single input line by separating the statements with a semicolon (;). DTR> SELECT FIRST; PRINTOO ID FIRST NAME STATUS 02943 E}{PER I ENCED CASS LAST NAME DEPT START DATE D98 2-Jan-80 LAST NAME DEPT START DATE NALEI.IO D98 3-Jan-76 LAST NAME DEPT START DATE D98 2-Jan-80 LAST NAME DEPT START DATE HAMMER D98 LAST NAME DEPT START DATE NALEI.IO D98 3-Jan-76 TERRY SALARY SUP ID $29,908 39485 DTR> SELECT LAST; PRINTOO ID FIRST NAME STATUS 84375 E}{PER I ENCED MARY SALARY SUP ID $56,847 39485 DTR> SELECT 1 ; PRINTOO ID FIRST NAME STATUS 02943 E>{ PER I ENCED CASS TERRY SALARY SUP ID $29,908 39485 DTR> SELECT NE}{T; PRINTOO ID FIRST NAME STATUS 49843 TRAINEE BART 4-Au~-81 SALARY SUP ID $26,392 39485 DTR> SELECT; PRINTOO ID STATUS FIRST NAME 84375 E}{PER I ENCED MARY SALARY SUP ID $56,847 39485 DTR> Modifying Data 7-3 7.3 Using the SHOW Command to Identify the Selected Record You can use the SHOW command to find out which record in a collection is the selected record. Type SHOW, followed by the collection name. DATATRIEVE returns this information, showing that the third record is the selected record in the CURRENT collection: OTR> SHOW CURRENTOOl Collection CURRENT DOMain: PERSONNEL NUMber of Records: 3 Selected Record: 3 OTR> 7.4 Modifying a Selected Record in a Collection To update or correct information in a selected record of a collection, follow these steps: 1. READY the domain for MODIFY access. 2. Form a collection of records with the FIND statement. 3. Use the SELECT statement to isolate the record you want to change. 7-4 Modifying Data 4. Use the PRINT statement to check that the selected record is the one you intend to change. 5. Use the MODIFY statement to change the selected record. 6. Use the PRINT statement to check that the record has been changed correctly. When you have selected a record that you want to modify in a collection, enter the keyword MODIFY. DATATRIEVE prompts you for a value for each elementary field in the record. You cannot modify the value of the primary key field, ID.· Use the TAB to retain the values of any fields you want to leave unchanged. Use the SPACE to enter a blank or a zero depending on the field definition. In the following example, an employee is transferring to a different department under a new supervisor and at an increased salary: DTR> READY PERSONNEL MODIFYoo DTR> FIND PERSONNEL WITH LAST_NAME = IHARRISON"oo [ 1 record found] DTR> SELECT; PRINToo 10 STATUS FIRST NAME 78823 E}< PER I ENCED LYDIA LAST NAME DEPT START DATE HARRISON F11 18-Jun-78 LAST NAME DEPT START DATE HARRISON Ell6 18-Jun-78 SUP SALARY 10 $llOt7ll7 00881 DTR> MODIFYoo Enter 10: @]loo Enter EMPLOYEE_STATUS: @]loo Enter FIRST_NAME: @]l(@) Enter LAST_NAME: @]loo Enter DEPT: Ell600 Enter START_DATE: @]l(@) Enter SALARY: llll580(@) Enter SUP_ID: 0001200 DTR> PRINToo 10 STATUS FIRST NAME 78823 E>{ PER I ENCED LYDIA SUP SALARY 10 $llllt580 00012 DTR> When you use the MODIFY statement, DATATRIEVE prompts you for your entry to each field of the record you want to modify. No modification of any part of the record takes place if you enter CTRL/Z before pressing RETURN at the end of the last field value prompt. DTR> FIND PERSONNEL WITH 10 [1 reco rd found] DTR> SELECTj PRINT(@) 10 381162 STATUS FIRST NAME EXPERIENCED BILL 3848200 LAST NAME SWAY DEPT START DATE T32 5-Ma}'-80 SUP SALARY 10 $5lltOOO 00012 (continued on next page) Modifying Data 7-5 DTR> MODIFY~ En t e rID: @§)@ Enter EMPLOYEE_STATUS: @§)@ En t e r FIR S T_ NAME: WI LL I AM@ Enter LAST_NAME: @§)@ Enter DEPT: ELlG@ Enter START_DATE: @§)@ En t e r Sal a r}': 58@ Enter SUP_ID: "'Z Execution terMinated by operator DTR> Because you entered CTRL/Z, the permanent record has remained unchanged: DTR> PRINT CURRENT@ ID 38L1G2 STATUS FIRST NAME E}{PER I ENCED BILL LAST NAME SWAY DEPT START DATE T32 5-Ma}'-80 SALARY SU ID $5L1,000 000 DTR> When you press RETURN instead of a value, TAB, or space in response to a MODIFY prompt, DATATRIEVE repeats the prompt until you enter something acceptable. The following example shows DATATRIEVE's responses to two other kinds of error: DTR> FIND PERSONNEL WITH ID [ 1 record found] DTR> SELECT; PRINTOO) ID STATUS FIRST NAME 78823 E}{PER I ENCED LYDIA 78823@ LAST NAME DEPT START DATE SALARY SL ![ HARRISON ELIG 18-Jun-78 $L1L1,580 ooe DTR> MODIFY@ Enter ID: 123L15G@ Truncation durinS assiSnMent Re - en t e rID: 123 L15@ En t e r EMPLOYEE_STATUS: NOl.! I CEm Validation error for EMPLOYEE_STATUS Re-enter EMPLOYEE_STATUS: "'Z Execution terMinated by operator DTR> The record definition for PERSONNEL restricts the entries you can make in the EMPLOYEE_STATUS field to either EXPERIENCED or TRAINEE. It therefore rejects the entry ((NOVICE." DATATRIEVE also rejects the 6-digit SUP _ID number, because the record definition restricts the field to five digits. 7.5 Modifying Fields in Indexed Data Files You can modify any field of a record in a sequential file. If you are working with an indexed file, however, you cannot change the primary key field. You may not be allowed to modify other key fields, as well, depending on the file's characteristics. 7-6 Modifying Data Some changes are simpler to do by specifying only the fields you want to change. At times it is easier to tab past the fields you do not want to change, rather than specifying the fields you do want to change. With the SHOW READY command, you can find out what type of data file is associated with a domain: DTR> SHOW READY(@) Read}' dOlllains: PERSONNEL: RMS INDEXED, PROTECTED MODIFY DTR> The word cCindexed" tells you that the data associated with the PERSONNEL domain is in an indexed file. The SHOW FIELDS command tells you which fields are keys: DTR> SHOW FIELDS(@) PERSONNEL PERSON ID [NuMber, indexed Key] EMPLOYEE_STATUS (STATUS) [Character string] EMPLOYEE_NAME (NAME) FIRST_NAME (F_NAME) [Character string] LAST_NAME (L_NAME) [Character string] DEPT [Character string] START_DATE [Date] SALARY [NufTlbe r] SUP_ID [NufTlber] DTR> In the PERSONNEL record definition, the ID field is the primary key. If you try to modify ID, DATATRIEVE sends an error message: DTR> READY PERSONNEL MODIFY(@) DTR> FIND PERSONNEL WITH LAST_NAME [1 reco rd found] DTR> SELECT;PRINT(@) ID STATUS FIRST NAME 78823 EXPERIENCED LYDIA "HARRISON"(@) LAST NAME DEPT START DATE HARRISON E4S 18-Jun-78 SALARY SUP ID $44 ,580 00012· DTR> MODIFY ID(@) En t e rID: 74252(@) AtteMPt to update Key field without change attribute Execution failed DTR> If you try to modify a key field, DATATRIEVE does not print an error message until the entire modification statement is complete. Then, it cancels the entire modification statement, making none of the changes you requested, as the following example shows: DTR> FIND PERSONNEL WITH ID [1 reco rd found] 78823(@) (continued on next page) Modifying Data 7-7 DTR> SELECT;PRINT®rn ID STATUS FIRST NAME 78923 EXPERIENCED LYDIA LAST NAME DEPT START DATE HARRISON E46 19-Jun-79 DTR> MODIFY ID,DEPT,SALARY,SUP_ID®rn Ente rID: 78901®rn Enter DEPT: Fll®rn Enter SALARY: 40747®rn Enter SUP_ID: 00891®rn AtteMPt to update key field without Execution failed DTR> PRINT®rn ID STATUS FIRST NAME 78923 EXPERIENCED LYDIA chan~e SUf ID SALARY $44,590 0001 attribute LAST NAME DEPT HARRISON E46 START DATE SUf ID SALARY 19-Jun-1979 $44,590 OOC DTR> If you specify a group field name in a MODIFY statement, DATATRIEVE prompts you for a value for each elementary field in the group. In this example, the query name for the group field EMPLOYEE_NAME is NAME, and includes both FIRST _NAME and LAST _NAME: DTR> FIND PERSONNEL WITH LAST_NAME [1 reco rd found] DTR> SELECT; PRINT®rn IFREIBURG"®rn FIRST NAME LAST NAME DEPT START DATE SALARY SUf ID 38465 EXPERIENCED JOANNE FREIBURG E46 20-Feb-80 $23 ,908 a8a~ ID STATUS DTR> MODIFY NAME®rn Enter FIRST_NAME: JOANNE®rn Enter LAST_NAME: KNECHTBURG®rn DTR> PRINT ID, NAME®rn ID FIRST NAME 38465 JOANNE LAST NAME KNECHTBURG DTR> 7.6 Modifying All Records in a Collection You can use MODIFY ALL to make changes in all the records ofa collection. Before modifying an entire collection, be very certain that you do not want certain records exempted from the change. If you make a mistake, it can lead to a lot· of work to replace the data you did not want to change. Do not be so afraid of MODIFY ALL that you do not use it when appropriate, but do be careful. To change all the records in the CURRENT collection, you must first establish the target collection as the CURRENT collection. 7-8 Modifying Data DTR> READY PERSONNEL MODIFYOO DTR> FIND PERSONNEL WITH SUP_ID [3 records found] DTR> PRINT ALL(BTI) ID STATUS FIRST NAME 02943 E}-{ PER I ENCED CASS 49843 TRAINEE BART 84375 E}-{PER I ENCED MARY 39485([IT) LAST NAME DEPT START DATE TERRY HAMMER NALEI.lO D98 D98 D98 2-Jan-80 4-Au9'-81' 3-Jan-78 SALARY SUP ID $29,908 39485 $28,392 39485 $58,847 39485 DTR> In the MODIFY statement, include the keyword ALL to specify that the change applies to all the records in the CURRENT collection, then list the fields you want to change. DTR> MODIFY ALL DEPT, SUP_ID([IT) Enter DEPT: C82([IT) Enter SUP_ID: 87485([IT) DTR> PRINT ALL(@) ID STATUS FIRST NAME 02943 E}< PER I ENCED CASS 49843 TRAINEE BART 84375 E}-{PERIENCED MARY LAST NAME DEPT START DATE TERRY HAMMER NALEl.IO C82 C82 C82 2-Jan-80 4-Au9'-81 3-Jan-78 SALARY SUP ID $29,908 87485 $28,392 87485 $58,847 87a85 DTR> 7.7 Modifying Records in a Record Stream You can modify records without forming a collection or using a SELECT state- , ment. You specify the records to be changed by putting the keywords ALL OF and a record selection expression (RSE) at the end of the MODIFY statement. For MODIFY statements that change entire record streams, DATATRIEVE prompts only once for each elementary field indicated by the keyword ALL or by the list of fields. DATATRIEVE then changes all the records in the record stream using that single set of values. Consequently, you should avoid using a statement such as MODIFY ALL OF PERSONNEL. MK-Q1101-OO Modifying Data 7-9 7.8 Modifying Specific Fields in a Record Stream To modify one field of the records in a record stream, specify the field name and the record selection expression in the MODIFY statement: DTR> PRINT PERSONNEL WITH SUP_ID = 00891m ID 32Ll32 TRAINEE 87701 TRAINEE LAST NAME DEPT START DATE SCHWEIK CHONTZ F11 F11 7-No 1.1-81 28-Jan-82 FIRST NAME STATUS THOMAS NATHANIEL SALARY SUP ID $2Gt723 00891 $2Llt502 00891 DTR> MODIFY SALARY OF FIRST 1 PERSONNEL WITH SUP_ID = 00891m Enter SALARY: 28G05m DTR> PRINT PERSONNEL WITH SUP_ID = 00891m ID 32Ll32 TRAINEE 87701 TRAINEE LAST NAME DEPT START DATE SCHWEIK CHONTZ F11 F11 7-NoI.l-81 28-Jan-82 FIRST NAME STATUS THOMAS NATHANIEL SALARY SUP ID $28tG05 00891 $2Llt502 00881 DTR> To modify two or more fields, list the fields before the OF rse portion of the statement, separating the fields with commas: DTR> PRINT PERSONNEL WITH SUP_ID = 00891 AND SALARY > 2500000 STATUS FIRST NAME LAST NAME DEPT START DATE 32Ll32 TRAINEE THOMAS SCHWEIK F11 7-Nol,l-81 ID SALARY SUP ID $28tG05 00891 DTR> MODIFY DEPTt SUP_ID OF PERSONNEL WITH SUP_ID = 00891 AND SALARY> 25000m Enter DEPT: ELlGm Enter SUP_ID: Ll8L17500l DTR> PRINT PERSONNEL WITH DEPT = IIELlGllm 10 FIRST NAME STATUS 32L132 TRAINEE 38LlG5 EXPERIENCED Ll8L175 EXPERIENCED 78923 EXPERIENCED THOMAS JOANNE GAIL LYDIA DTR> 7-10 Modifying Data LAST NAME DEPT START DATE SALARY SUP ID SCHWEIK KNECHTBURG CASSIDY HARRISON ELlG ELlG ELlG ELlG 7-NoI.l-81 20-Feb-80 2-Ma}'-78 1.9-Jun-79 $28tG05 $23t908 $55tLl07 $LlLlt590 Ll8Ll75 Ll8Ll75 00012 00012 Erasing Data 8 Sometimes you have to remove records from your data file. For an indexed data file like the one associated with the PERSONNEL domain, you can use the ERASE command. You cannot erase records from a sequential file. To remove data from a sequential file, however, you can use the MODIFY statement. B.1 Using the ERASE Statement on Indexed Files Because ERASE destroys records, use your judgment to prevent accidental loss of data. To use the ERASE command, you must ready a domain for WRITE access: DTR> READY PERSONNEL WRITEOO DTR> 8.1.1. Erasing a Selected Record To erase a selected record, follow these steps: 1. Establish a collection containing the record you want to erase. 2. Select that record. 3. Type ERASE and press RETURN. The following example first creates and then erases a record in PERSONNEL. DTR> READY PERSONNEL WRITEOO DTR> STORE PERSONNELOO Enter ID: 0001300 Enter EMPLOYEE_STATUS: TRAINEEOO Enter FIRST_NAME: PETEROO Enter LAST_NAME: SWAYZEOO Enter DEPT: 51700 Enter START_DATE: 1-Sep-198200 Enter SALARY: 2015900 Enter SUP_ID: 8728900 (continued on next page) 8-1 DTR> FIND PERSONNEL WITH DEPT [1 record found] DTR> SELECT;PRINT(@') ID FIRST NAME STATUS 00013 TRAINEE PETER DTR> ERASE(@,) DTR> PRINT(@,) DTR> No record selectedt DTR> "B17"(@') LAST NAME DEPT START DATE SWAYZE B17 1-Sep-82 printin~ SALARY SUP ID $20,159 8782 whole collection DATATRIEVE prints no records because you have erased the only record in the collection. If the CURRENT collection had contained more than one record, the PRINT statement would have displayed the remaining records in the collection. Even though you erase the only record in a collection, however, the collection does not disappear. The record has been erased from the data file and removed from the collection. Only its slot in the collection remains, and that slot is empty. The empty slot disappears only when the collection is released by the RELEASE, FINISH, or EXIT commands or when the collection is sorted or renamed. DTR> SHOW CURRENT(@') Collection CURRENT DOMain: PERSONNEL NUMber of Records: Selected Record: 1 DTR> FIND PERSONNEL WITH LAST_NAME [0 records found] DTR> 8.1.2 "SWAYZE"(@') Erasing a Collection of Records To ERASE all the records in a collection, establish the collection and type ERASE ALL. Pay careful attention to the extent and content of the collection. Once you ERASE the records, you cannot recover them. DTR> FIND PERSONNEL WITH DEPT = "G20"(@') [3 records found] DTR> PRINT ALL(@') FIRST NAME LAST NAME DEPT START DATE 87289 E}-( PER I ENCED LOUISE 88001 E}-( PER I ENCED DAt.JI D 91023 TRAINEE STAN DEPALMA LITELLA WITTGEN G20 G20 G20 28-Feb-79 ll-Nol,l-80 23-Dec-81 ID STATUS DTR) ERASE ALL(@') DTR> PRINT (@') No record selectedt DTR> printin~ SALARY $57,598 000 $34,933 872: $25,023 872: whole collection The PRINT statement displays no records because all the records in the collection have been erased and removed from the data file. 8-2 Erasing Data SUI ID 8.1.3 Erasing a Record Stream To ERASE all the records in a record stream, specify the RSE in the ERASE ALL statement. As with collections, pay careful attention to the extent and content of the record stream. DTR> PRINT PERSONNEL WITH DEPT = IF11"00 ID STATUS FIRST NAME 00891 E~<PER I ENCED FRED NATHANIEL 87701 TRAINEE LAST NAME DEPT START DATE HOWL CHONTZ F11 F11 9-Apr-7B 28-Jan-82 SALARY SUP ID $59,59£1 00012 $2£1,502 00891 DTR> ERASE ALL OF PERSONNEL WITH DEPT IF11"(0) DTR> PRINT PERSONNEL WITH DEPT = IF11"00 DTR> 8.2 Using the MODIFY Statement on Sequential Files You cannot erase records from a sequential data file. You can, however, remove the data stored in records you want to eliminate from the file. Use the MODIFY statement to substitute a blank record for a record you want to remove from the data file. Use any form of the MODIFY statement that chooses the records you want to eliminate. Respond to the prompts for field values by typing a space and pressing RETURN. The space changes the value of numeric fields to zero and the value of character fields to blank. Erasing Data 8-3 Writing Simple Reports 9 The DATATRIEVE Report Writer arranges your data in formats that are easy to read. You can control the format of the report or allow the Report Writer to do some or all the formatting automatically. This chapter introduces the basic formatting capabilities of the Report Writer. 9.1 The General Features of a Report When you display records with the PRINT statement, you are creating a simple form of report: DTR> READY PERSONNEL(@) DTR> FIND PERSONNEL WITH SUP_ID 00012(@) [8 records found] DTR> PR·I NT ALL(@) ID STATUS 00012 EHPERIENCED 381162 EHPERIENCED 391185 E>{ PER I ENCED ll8ll75 EXPERIENCED 75639 TRAINEE 756110 TRAINEE 78923 E}< PER I ENCED 871165 E}<PERIENCED FIRST NAME LAST NAME CHARLOTTE BILL DEE GAIL MIKE BEN LYDIA ANTHONY SP!l.JA SWAY TERRICK CASSIDY MILLER PUTNAM HARRISON IACOBONE DEPT TOP T32 D98 Ell6 Tllll Tllll Ell6 C82 START DATE 12-Sep-72 5-Ma}'-80 2-Ma}' -77 2-Ma}'-78 6-Feb-81 6-Feb-81 19-Jun-79 2-Jan-73 SALARY SUP ID $75t892 00012 $5lltOOO 00012 $55t829 00012 $55tll07 00012 $16t750 00012 $16t500 00012 $llllt590 00012 $58tll62 00012 DTR> The PRINT statement gives you some control over the display of your data, but the Report Writer can do more formatting for you than the PRINT statement can. Type the following commands and statements to produce a report based on the collection you havejust printed using the PRINT statement. This report is the 9-1 simplest type you can create with the Report Writer. The RW> prompt shows when you are using the Report Writer: DTR> FIND PERSONNEL WITH SUP_ID [8 records found] DTR> REPORT CURRENT@] RW> PRINT PERSONoo RW> END_REPORToo = 0001200 2-Nov-82 Pa9'e 1 ID STATUS FIRST NAME LAST NAME 00012 E}<PERIENCED E}<PER I ENCED E}-{PERIENCED E}< PER I ENCED TRAINEE TRAINEE EXPERIENCED E}<PER I ENCED CHARLOTTE BILL DEE GAIL MIKE BEN LYDIA ANTHONY SP!l.IA SWAY TERRICK CASSIDY MILLER PUTNAM HARRISON IACOBONE 38aG2 39a85 a8a75 75G39 75GaO 78923 87aG5 DEPT TOP T32 D98 EaG Taa Taa EaG C82 START DATE 12-Sep-72 5-May-80 2-Ma}'-77 2-Ma}'-78 G-Feb-81 G-Feb-81 19-Jun-79 2-Jan-73 SALARY $75,892 $5a,OOO $55,829 $55,a07 $lG,750 $lG,500 $aa,590 $58,aG2 SUP ID 00012 00012 00012 00012 00012 00012 00012 00012 DTR> ~~PERSON" is a group field, called a top-level field, that contains all the other fields of the PERSONNEL record. When you use the Report Writer PRINT statement, you cannot simply type PRINT by itself. You must type a field or fields after PRINT. When you enter the Report Writer statement ~~PRINT PERSON", the Report Writer responds with all the information in the collection because the field PERSON contains all the fields in the record. If you wished, you could type PRINT SALARY or PRINT ID, SALARY. Notice that the report does not display immediately after you type the PRINT statement. You must type END_REPORT in order to see the report. This report, unlike the output of the PRINT statement, has the current date, a page number, and data columns evenly spaced across the entire page. If there are too many lines for a single page, the Report Writer skips automatically to the next page, printing the appropriate page number each time it starts a new page. 9.2 The Report Specification You can create a collection before you type a REPORT statement, or you can form a record stream with an RSE in the REPORT statement itself. The collection or the record stream supplies the data for your report. The series of statements that creates the report forms a unit called the report specification: • The REPORT statement starts the report specification. As you will see later, you can specify an RSE in the REPORT statement. 9-2 Writing Simple Reports • The Report Writer PRINT statement specifies the fields containing the data you want to report. In the example, PERSON is the group field that contains all the fields in the PERSONNEL record definition. • To give a report a title, use the SET REPORT _NAME statement. Enclose the name within quotation marks. If you do not specify a name, DATATRIEVE prints the report without one. • The END_REPORT command ends the report specification. The following example shows you how to use the SET REPORT _NAME statement in the report specification: DTR> FIND FIRST 1 PERSONNELm [1 Record found] DTR> RW> RW> RW> REPORT CURRENTm SET REPORT_NAME = "FIRST PERSONNEL RECORD"m PRINT PERSONm END_REPORTm' 1 G-No 1)-82 Page 1 FIRST PERSONNEL RECORD 10 STATUS FIRST NAME 00012 EXPERIENCED CHARLOTTE LAST NAME DEPT START DATE SALARY SUP 10 TOP 12-Sep-72 $75t892 00012 DTR> If you do not type REPORT CURRENT but just REPORT, DATATRIEVE reports on the current collection. 9.2.1 Multiple-Line Report Names To give a report a multiple-line title, enclose each line in quotation marks, and separate each line from the next with a slash. Report names must be less than 100 characters. The sample report specification in the following section uses the following multiple-line report name: RW> SET REPORT_NAME 9.2.2 = "TRAINEE EMPLOYEES"/"BY"/"DEPARTMENT AND SALARY"(BTIJ The COlumns_Page Option By using the Report Writer's SET COLUMNS_PAGE statement, you can control the width of the report. The word ((column" in the SET COLUMNS_PAGE statement refers to the number of spaces in the line, not to the columns of data in the report. The number of columns you specify must be between 1 and 255. If you do not specify a number, the Report Writer uses a default value of80. The next sample report specification uses this statement: RW> SET COLUMNS_PAGE = 50m Writing Simple Reports 9-3 The REPORT command in,this example specifies a record stream with the following RSE: CURRENT SORTED BY DEPT, SALARY. The PRINT statement specifies the fields ID, NAME, DEPT, SALARY: OTR> FIND PERSONNEL WITH STATUS = "TRAINEE"ru [8 records found] OTR> REPORT CURRENT SORTED BY DEPT, SALARYru RW> SET REPORT_NAME = "TRAINEE EMPLoYEES"/"BY"/" DEPARTMENT AND SALARY"ru RW> SET COLUMNS_PAGE = 50ru RW> PR I NT ID, NAME, DE PT, SALARYru RW> END_REPoRTru TRAINEE EMPLOYEES BY DEPARTMENT ANO SALARY 2-No\)-83 Page 1 10 FIRST NAME LAST NAME OEPT SALARY 123£15 £188£13 126£13 32£132 3£1£156 £18573 756£10 75638 HENRIETTA BART JEFF THOMAS HANK SY BEN MIKE MILLER HAMMER TASHKENT SCHWEIK MORRISON KELLER PUTNAM MILLER C82 C82 E£16 T32 T32 T£1£1 T£1£1 $26,382 $32,818 $28,605 $30,000 $31 ,5£16 $16,500 $16,750 OTR> 9-4 Writing Simple Reports If you make the COLUMNS_PAGE setting too small, the Report Writer moves the fields that do not fit to the next line of the display. 9.2.3 Print List Options The Report Writer allows you to control many aspects ofa report format. With the Report Writer you can: • Create new fields, by computing new information from the data available • Change column headers (the labels at the tops of columns) • Create new column headers for new fields • Print summary lines at the bottom of a page or the end of a report • Print a count of the records making up the report • Compute averages of numerical fields in the report • Specify the format of lines in the report • Specify some simple statistical functions These are some of the options the Report Writer offers you. See the DATATRIEVE-ll Guide to Writing Reports for details of these and other options. 9.3 Output of Reports Unless you work on a hard copy terminal, the reports created in the previous examples appear on your video screen and disappear as you continue working. To save a report, you can select an output device or file for it as a part of the REPORT statement. 9.3.1 Output to a Line Printer To get a copy of your report from a line printer, type ON LP: at the end of the REPORT statement: RW> REPORT ON LP:lBTI) If the REPORT statement contains an RSE, put the output specification after the RSE: RW> REPORT PERSONNEL WITH DEPT = IG20" ON LP:(@j 9.3.2 Output to a Disk File If you want to store your report in a disk file, type the file specification after ON at the end of the REPORT statement. The following command creates a file called REPORT.TXT in your directory. RW> REPORT TRAINEES ON REPORT. T}<TlBTI) Writing Simple Reports 9-5 If you send your report to a disk file, you can use operating system utilities to print a hard copy of it at your convenience. You can also make it available for display on other terminals, or send it across a network link. 9.4 Savi n9 Report Specifications When you create a report you will want to use again, you can save the report specification by defining the report as part of a procedure. A procedure is a sequence of commands and statements that you can construct to perform a function you use frequently and want to avoid retyping each time you use it. Chapter 9 of the DATATRIEVE-ll User's Guide explains defining procedures. Chapter 1 of the DATATRIEVE-ll Guide to Writing Reports discusses using procedures to produce reports. 9.5 Summary Report specifications can be complex because the Report Writer gives you so many ways to control the format. Mastery of report writing comes with patience and practice. Remember these seven basic characteristics of report writing with the DATATRIEVE Report Writer: • You must READY the domain containing the data you want to report. • The data you want to report must be contained in a collection or in the record stream you create in the REPORT statement. • The REPORT statement gives you access to the Report Writer. • The RW> prompt tells you to enter Report Writer statements. • You can give your report a name with the SET REPORT-NAME statement. If you specify a name, you must enclose it in quotation marks. • In the Report Writer PRINT statement, you must specify the fields containing information you want to report. You can have only one PRINT statement in a report specification. • You must end the report specification with th3 END_REPORT statement. With the statements presented in this chapter, you can now experiment with the PERSONNEL data or with data from a domain you have defined for yourself, and practice writing your own sample reports. 9-6 Writing Simple Reports Glossary Boolean operators Symbols or phrases which enable you tojoin two or more expressions containing relational operators. Boolean operators are AND, OR, NOT, and BUT. For example, the expression SALARY < 60000 BUT SALARY NE a contains the Boolean operator ((BUT". The symbols ((<" and NE are relational operators. Collection A special type of record stream formed with the FIND statement. You can also name a collection. You can refer to a collection in subsequent statements until you replace it wi th another collection, release it with the RELEASE command, finish the domain from which it derives, or exit DATATRIEVE. You can have several named collections available at once. Column headers In a report or in the output of a PRINT statement, the headings that label the columns of data. Command file A text file containing DATATRIEVE commands and statements. You can create command files with the Application Design Tool (ADT), the EXTRACT command, or a text editor. Data dictionary An indexed file used to store DATATRIEVE definitions and access privileged information. Data file A collection of related data records. Glossary 1 Data record A body of related information that is the basic unit for storing data. For example, the several items of data about an individual employee in the PERSONNEL domain make up a record for that employee. Database A collection of records maintained on a computer storage device and organized to facilitate immediate and accurate inquiry and update. Detail lines The lines containing data items in a report. Domain A data structure that associates a name with the relationship between a data file and a record definition. Using the domain name gives access to information in the data file as interpreted by the record definition. Elementary field A record segment containing one item of information. Field A segment of a data record. For example, each PERSONNEL record contains these fields: ID, employee status, employee name, department, starting date, salary, and the ID of the employee's supervisor. Group field A record segment containing one or more elementary fields. In PERSONNEL, EMPLOYEE_NAME is a group field containing the employee's first and last names. Index key A field that is the basis for the indexing of an indexed file. For the domain PERSONNEL, the index key is ID. DATATRIEVE indexes the records by identification numbers. You can use primary keys, which you cannot change, and alternate keys. Indexed file A data file that includes records and an index specifying the location of each record in the file. Primary key The index key whose value determines the order of records in an indexed file. You cannot modify or erase the value in a primary key field. 2 Glossary Procedure A fixed sequence of commands, statements, clauses, or arguments that you create, name, and store in the data dictionary. Query header A substitute column header that replaces the field name when DATATRIEVE displays values from a field on your terminal. You cannot use query headers as query names. Query name A synonym for a field name, usually a shorter word to make input easier to type and remember. For example, you can type STATUS for EMPLOYEE_STATUS to refer to that field in DATATRIEVE's sample domain PERSONNEL. Record definition An entry in a data dictionary that describes the fields in a record. Record selection expression (RSE) A phrase defining specific conditions individual records must meet before they are included in a record stream. Record stream A temporary group of related records formed by a record selection expression. Relational operators Symbols or phrases you can use to compare values. For example, in the DATATRIEVE statement FIND PERSONNEL WITH SALARY> 50000, SALARY> 50000 is a Boolean expression containing the relational operator ((>" (greater than). Report header The heading of a DATATRIEVE Report, consisting of an optional, centered report-name and, at the top-right corner of the report, a date and a page number. Report specification A series of Report Writer statements that creates a report and specifies its format. Restriction clause A phrase allowing you to specify the maximum number of records in a record stream. Glossary 3 Selected record In a collection, the one record marked by the SELECT statement, and available for display or modifying without specifying a record selection expression. Sequential file A file whose records are physically stored next to each other in a computer's storage device. You cannot delete records from a sequential file with DATATRIEVE. Sort key A field that forms the basis for sorting. For example, you can rearrange the records in DATATRIEVE's sample domain PERSONNEL according to department by using the sort key DEPT. 4 Glossary Index < See LESS_THAN relational operator > See GREATER_THAN relational operator A Accessing domains, 2-4 to 2-5 ADT command, 3-6 See Also Application Design Tool AND Boolean operator, 6-5 Application Design Tool defining data with, 3-1 to 3-9 sample session, 3-4 to 3-8 ASCENDING sort key, 6-8 Assigning query names using the ADT command, 3-2 B BETWEEN relational operator, 6-4 BUT Boolean operator, 6-5 c Collections, 6-10 to 6-21 changing content of, 6-19 to 6-20 displaying, 6-11 to 6-12 erasing, 8-2 forming, 6-11 Collections (Cont.) making new CURRENT from old, 6-14 to 6-15 naming, 6-15 to 6-17 releasing, 6-20 to 6-21 renaming, 6-18 to 6-19 SHOW command, 6-14 showing names of, 6-17 to 6-18 sorting, 6-12 to 6-14 CONTAINING relational operator, 6-4 CTRL/Z, 2-5, 5-3 CURRENT in record selection expressions, 6-15 D Data dictionary creating, 3-9 placing definitions into, 3-8 to 3-9 Data types, 3-2 to 3-:3 DEFINE DICTIONARY command, 3-9 DEFINE DOMAIN command, 3-9 DEFINE FILE command, 3-9 DEFINE RECORD command, 3-9 Defining data outside the Application Design Tool, 3-9 to 3-10 data with Application Design Tool, 3-1 to 3-9 DESCENDING sort key, 6-8 Index-1 Displaying DATATRIEVE objects, 2-4 See also SHOW command dictionary name, 2-2 Domains planning, 3-2 to 3-4 sample, 1-3 E Ending a DATATRIEVE session, 2-5 EQUAL relational operator, 6-4 Erasing data, 8-1 to 8-3 EXIT command, 2-5 Exiting an ADT session, 3-5 DATATRIEVE, 2-5 Information management, 1-1 Invoking an ADT session, 3-6 DATATRIEVE, 2-1 K Keys alternate index, 3-4 duplicate values, 3-4 primary index, 3-3 L LESS_EQUAL relational operator, 6-4 LESS_THAN relational operator, 6-4 F M Fields data types, 3-2 to 3~3 naming using the ADT command, 3-2 query names, 3-2 size, 3-3 Files indexed, 3-3 to 3-4, 7-7 sequential, 3-3 to 3-4 FIND statement, 6-11 FINISH command, 6-21 MODIFY statement ALL, 7-8 to 7-9 preventing, 7-5 to 7-6 Modifying data, 7-1 to 7-10 selected record, 7-4 to 7-6 G GREATER-EQUAL relational operator, 6-4 GREATER-THAN relational operator, 6-4 Guide Mode, 4-3 H HELP command, 4-1 to 4-2 Indexed files, 3-3 to 3-4 ERASE statement with, 8-1 to 8-3 modifying, 7-6 to 7-8 Index-2 N Naming fields using the ADT command, 3-2 NOT Boolean operator, 6-5 NOT_EQUAL relational operator, 6-4 o OR Boolean operator, 6-5 p Primary index key, 3-3 PRINT statement, 6-1 creating reports with, 9-1 displaying data with, 6-5 to 6-10 Q Query names, 3-2 R READY command, 2-4 to 2-5 Record selection expression, 6-2 to 6-5 Record stream, 6-1 displaying fields, 6-9 to 6-10 erasing, 8-2, 8-3 forming, 6-2 to 6-5 limiting, 6-2 to 6-6 modifying fields, 7-H to 7-10 modifying records in, 7-9 to 7-10 sorting, 6-6 to 6-9 stopping display, 6-10 Records with missing values, 5-3 Relational operators, 6-4t RELEASE command, 6-20 Reports, 9-1 to 9-6 general features, 9-1 to 9-2 output to disk file, 9-5 output to line printer, 9-5 print list options, 9-5 saving specifications, 9-6 specification, 9-2 to 9-5 Retrieving data, 6-1 to 6-21 displaying all records, 6-1 RSE See Record selection expression Sequential files, 3-3 to 3-4 MODIFY statement with, 8-3 modifying, 7-1 to 7-6 SET GUIDE command, 4-3 SET statement (Report Writer) COLUMNS_PAGE, 9-3 SETUP.DTR command RSTS / E systems, 2-2 RSX systems, 2-2 SHOW ALL command, 2-3 SHOW DICTIONARY command, 2-2 SHOW DOMAINS command, 2-4 SHOW READY command, 2-4 SHOW RECORDS command, 2-4 Sort keys, 6-7 Starting an ADT session, 3-6 DATATRIEVE, 2-1 to 2-4 STORE statement, 5-1 to 5-5 cancelling, 5-3 data types, 5-4 REPEAT with, 5-3 T Terminology DATATRIEVE, 1-2 s SELECT statement, 7-1 to 7-5 forms of, 7-2 to 7-3 SHOW command with, 7-3 to 7-4 Index-3 HOW TO ORDER ADDITIONAL DOCUMENTATION DIRECT TELEPHONE ORDERS In Continental USA and Puerto Rico call 800-258-1710 In Canada call 800-267-6146 In New Hampshire, Alaska or Hawaii call 603-884-6660 DIRECT MAIL ORDERS (U.S. and Puerto Rico*) DIGITAL EQUIPMENT CORPORATION P.O. Box CS2008 Nashua, New Hampshire 03061 DIRECT MAIL ORDERS (Canada) DIGITAL EQUIPMENT OF CANADA LTD. 940 Belfast Road Ottawa, Ontario, Canada K1 G 4C2 Attn: A&SG Business Manager INTERNATIONAL DIGITAL EQUIPMENT CORPORATION A&SG Business Manager c/o Digital's local subsidiary or approved distributor Internal orders should be placed through the Software Distribution Center (SDC), Digital Equipment Corporation, Northboro, Massachusetts 01532 *Any prepaid order from Puerto Rico must be placed with the Local Digital Subsidiary: 809-754-7575 Introduction to DATATRIEVE-11 AA-X025A-TK Reader's Comments Note: This form is for document comments only. DIGITAL will use comments submitted on this form at the company's discretion. If you require a written reply and are eligible to receive one under Software Performance Report (SPR) service, submit your comments on an SPR form. . Did you find this manual understandable, usable, and well-organized? Please make suggestions forimprovement. _______________________________________________________________ Did you find errors in this manual? If so, specify the error and the page number. _________ Please indicate the type of user/reader that you most nearly represent. D D D D D D Name Assembly language programmer Higher-level language programmer Occasional programmer (experienced) User with little programming experience Student programmer Other (please specify) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ Date __________________________________ Organization ______________________________________________________________ Street _______________________________________________________________________ City ___________________________________ State ___________ ZiporCode Country ------..:.Do Not Tear - Fold Here and Tape - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IIIIII No Postage Necessary if Mailed in the United States BUSINESS REPLY MAIL FIRST CLASS PERMIT NO.33 MAYNARD MASS .. POSTAGE WILL BE PAID BY ADDRESSEE ATTN: DISG Documentation ZK02-2/N53 DIGITAL EQUIPMENT CORPORATION 110 SPIT BROOK ROAD NASHUA, N.H. 03062 -------Do Not Tear - Fold Here and Tape - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ':', ) Update Notice #1 November 1987 Introduction to DATATRIEVE-11 AD-X025A-T1 Copyright © 1987 by Digital Equipment Corporation. All Rights Reserved. ) New and Changed Information This update contains changes and additions made to the Introduction to DATATRIEVE-ll for Version 3.2. Instructions ) ) Place the enclosed pages in the Introduction to DATA TRIEVE-l 1 Version 3 as replacements for or additions to current pages. Change bars on replacement pages indicate changed text. For new pages and pages where most of the text has been substantially revised, no change bars are used. Instead, only the Version 3.2 release date is shown on the bottom corner of the page. Old Page New Page Title Page/Copyright iii to x 2-1/2-2 Chapter 4 Chapter 5 Index How to Order Reader's Comments/Mailer Title Page/Copyright iii to viii 2-1/2-2 Chapter 4 Chapter 5 Index How to Order Reader's Comments/Mailers ) Introduction to DATATRIEVE-11 Order No. AA-X025A-TK Including AD-X025A-T1 ) November 1987 This document introduces you to basic DATATRIEVE-ll commands. / \ OPERATING SYSTEMS: RSX-IIM RSXIIM-PLUS RSTS/E Micro/RSX Micro/RSTS VMS with RSX-ll SOFTWARE VERSION: DATATRIEVE-ll V3.2 digital equipment corporation, maynard, massachusetts The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this document. The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license. No responsibility is assumed for the use or reliability of software on equipment that is not supplied by DIGITAL or its affiliated companies. Copyright © 1983, 1987 by Digital Equipment Corporation. All Rights Reserved. The postage-paid Reader's Comments forms at the end of this document request your critical evaluation to assist us in preparing future documentation. The following are trademarks of Digital Equipment Corporation: ~D~DDmD ™ MicroVAX MicroVMS ACMS CDD DATATRIEVE DEC DECnet DECUS Micro/RSTS Micro/RSX PDP RALLY Rdb/ELN RdbNMS ReGIS RSTS RSX TDMS TEAMDATA UNIBUS VAX' VAXcluster VAXinfo VAX Information Architecture VAXNMS VMS VT ) Contents Page How to Use This Manual 1 vii Introduction 1.1 1.2 1.3 DATATRIEVE Terminology. Using DATATRIEVE-11. The Sample Domains . . '. . · 1-2 2.1 Starting DATATRIEVE . . . . . . . . . . . . . . . . . . . . . Displaying Information About Your DATATRIEVE Environment Accessing Domains . . . . . . . Ending a DATATRIEVE Session . . . . . . . . . . . . . . . . · 2-4 · 2-4 · 2-5 ... Starting and Stopping a DATATRIEVE Session · 1-2 · 1-2 2· 2.2 2.3 2.4 3 Defining Data with ADT 3.1 ) 3.2 3.3 4 Planning a DATATRIEVE Domain Using ADT . . . . . . . . . . . · 3-4 3.2.1 Invoking the .CMD File . · 3-8 Defining Domains Outside ADT . · 3-9 · 3-2 HELP and GUIDE Mode: Quick-Reference Section 4.1 4.2 5 · 2-1 Using DATATRIEVE HELP. Using GUIDE Mode. · 4-1 · 4-2 Storing Data 5.1 5.2 5.3 5.4 5.5 5.6 Preparing a Domain for Storing Data . . . . . . . . Using the STORE Statement . . . . . . . . . . . . Preventing a STORE Statement from Taking Effect . Creating a New Record Without Complete Information Storing Two or More Records At a Time . . . . . Storing the Correct Type of Data in New Records . . . · 5-1 · 5-2 · 5-2 · 5-3 · 5-3 · 5-4 \ ) November 1987 iii 6 Retrieving Data 6.1 6.2 Displaying All Records in a Domain. Selecting a Group of Records . . . . 6.2.1 6.2.2 6.3 6.4 6.5 6.6 6.7 Examples of Displaying Data with the PRINT Statement Sorting Records in Record Streams . . Displaying Fields from Record Streams Stopping the Display. of Record~ . Using Collections . . . . . . . . . . . 6.7.1 6.7.2 6.7.3 6.7.4 6.7.5 6.7.6 6.8 7 Releasing Collections . . . . Using the FINISH Command · 6-5 · 6-7 · 6-9 6-10 6-11 6-11 6-11 6-13 6-14 6-14 6-15 6-15 6-17 6-18 6-19 6-20 6-21 Using the SELECT Statement with a Collection . . . . . . . Using Other Forms of the SELECT Statement. . . . . . . . Using the SHOW Command to Identify the Selected Record. Modifying a Selected Record in a Collection . Modifying Fields in Indexed Data Files Modifying All Records in a Collection . . . . Modifying Records in a Record Stream. . . . Modifying Specific Fields in a Record Stream · 7-1 · 7-2 · 7-4 · 7-4 · 7-6 · 7-8 · 7-9 7-10 Erasing Data 8.1 8.2 iv Showing the Names of Existing Collections Naming an Unnamed Collection. . . . . . Changing the Content of a Named Collection · 6-2 · 6-3 Modifying Data 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 8 Forming Collections. . . . . . Displaying the CURRENT Collection Displaying Sorted Records in the CURRENT Collection Displaying Information About the CURRENT Collection. Making aNew CURRENT Collection from an Old One Using the CURRENT Collection in RSEs . Naming a Collection. . . . . . . . . . . . . . . . 6.8.1 6.8.2 6.8.3 6.9 6.10 Specifying the Number of Records in a Record Stream. Limiting Record Streams by Specifying Values . · 6-1 · 6-2 Using the ERASE Statement on Indexed Files. · 8-1 8.1.1 8.1.2 8.1.3 · 8-1 · 8-2 · 8-3 Erasing a Selected Record . . . Erasing a Collection of Records . . . . Erasing a Record Stream . . . . . . . Using the MODIFY Statement on Sequential Files · 8-3 November 1987 ) 9 Writing Simple Reports 9.1 9.2 The General Features of a Report . The Report Specification. · 9-1 · 9-2 9.2.1 9.2.2 9.2.3 · 9-3 · 9-3 · 9-5 Output of Reports . 9.3 9.3.1 9.3.2 9.4 9.5 Multiple-Line Report Names. The Columns_Page Option Print List Options. Output to a Line Printer Output to a Disk File Saving Report Specifications. Summary. · 9-5 · 9-5 · 9-5 · 9-6 · 9-6 Glossary ') /' Index Figures 1-1 4-1 4-2 The DATATRIEVE Domain. The HELP Screen. The HELP SHOW screen · 1-3 · 4-1 · 4-2 ) Tables 6-1 Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 November 1987 v ) How to Use This Manual This book introduces you to DATATRIEVE-l1. It begins with a brief explanation of information management and the use ofDATATRIEVE. It then guides you through the basic tasks you can perform with DATATRIEVE. Intended Audience The Introduction to DATATRIEVE-ll assumes you can use your terminal to log in to your local computer system and display the contents of your file directory. If you need to review how to do that, consult the user's guide for your operating system. I This book addresses people who are unfamiliar with DATATRIEVE-l1. I Structure There are nine chapters in this introduction: Chapter 1 Briefly describes information management and lists some basic DATATRIEVE functions Chapter 2 Supplies information about what you have to do to begin using DATATRIEVE, describes some of the basic commands and statements that tell DAT ATRIEVE what to do, and tells you how to leave DATATRIEVE Chapter 3 Explains how to define information for DATATRIEVE using ADT Chapter 4 Describes the use of Help and Guide Mode to give you online assistance while using DATATRIEVE Chapter 5 Explains how to store information with DATATRIEVE Chapter 6 Describes a variety of ways you can retrieve data ) November 1987 vii Chapter 7 Contains information about modifying information you have stored previously Chapter 8 Explains how to erase data Chapter 9 Describes some of the basic features of the DATATRIEVE Report Writer Conventions The following list explains the special symbols used in this book: (@) This symbol tells you to press the RETURN key on the keyboard of your terminal. This symbol tells you to press the TAB key on the keyboard of your terminal. This symbol tells you to press the CTRL (control) key and a letter key (usually Z or C) at the same time. > The symbol> on a line by itself represents the system prompt. color Text printed in red shows the lines you type while doing the examples. Related Manuals DATATRIEVE-ll Guide to Writing Reports DATATRIEVE-ll User's Guide viii November 1987 \ ) Starting and Stopping a DATATRIEVE Session 2 \ ) This chapter shows you how to: • Start DATATRIEVE • Show what data is available to you • Get ready to display your data • Stop DATATRIEVE 2.1 Starting DATATRIEVE To start DATATRIEVE, type: DTRffiIT) DATATRIEVE displays the following message: PDP-11 DATATRIEVEt DEC Query and Report SysteM Version: V3.2t 8-Aug-87 Type HELP for help DTR> If you do not get this startup banner, type either RUN $DTR or the symbol defined by your system manager to invoke DATATRIEVE. ) November 1987 2-1 For RSTSJE systems type: DTR> @LB:SETUP.DTROO) For RSX systems type: DTR> @LB:[1 tZJSETUP.DTROO) This command creates a dictionary for you called SAMPLE.DIC, enters the domain and record definitions into your dictionary, and copies the data files into your directory. The command displays the following information: ******************************************************************** Datatrieve is now setting UP its saMPle definitions and data in your private dictionary SAMPLE.DIC. The data files will be stored in your default directory. There will be a data files created: YACHTt OWNERt FAMILY and PERSON. ******************************************************************** The commands and definitions scroll on your screen, and the display concludes with the message: ******************************************************************** The Datatrieve saMPle definitions and data have been installed. ******************************************************************** DTR> If you do not know whether you are using a RSTS/E or a RSX system, ask your system manager. In response to the @SETUP.DTR command, DATATRIEVE may display a message that SAMPLE.DIC already exists. You can ignore this message. To display the name of your dictionary, type: DTR> SHOW DICTIONARYOO) For RSTSJE systems DATATRIEVE responds with a message resembling the following: The current dictionary is SY:[l t170JSAMPLE.DIC DTR> The message for RSX systems resembles the following: The current dictionary is DBO:[l tZJSAMPLE.DIC DTR> 2-2 Starting and Stopping a DATATRIEVE Session \ ) HELP and Guide Mode: Quick-Reference Section 4 ) 4.1 Using DATATRIEVE HELP A HELP program is available that can answer many questions you may have as you are using DATATRIEVE. You can call it by typing HELP and pressing RETURN whenever you are at the DTR> prompt. '\ When you request HELP, your screen appears as shown in Figure 4-1. / DTR> HELPffiill Two levels of assistance are availablet basic and advanced. To Set help for the eleMentarY DATATRIEVE stateMentSt type HELP followed by the naMes of the stateMents for which help is re9uired. To get a list of the topics for which help is availablet t,'pe HELP HELP To get assistance with advanced DATATRIEVE stateMentSt type HELP ADVANCED followed by the naMes of the stateMents for which help is re9uired. To get a list of the topics for which advanced is availablet type HELP ADVANCED HELP Paired S9uare bra~kets indicate that the enclosed clause is optional. Capital letters indicate DATATRIEVE keywords. Words in lower case indicate that a user supplied naMe or value is re9uired. DTR> Figure 4-1: The HELP Screen ) November 1987 4-1 The best way to become familiar with HELP may be to type HELP HELP at the DTR> prompt. DATATRIEVE displays a list of topics; HELP provides information about each of them. Type HELP and one of those topics to find out more about the topic. While you are learning how to use HELP, you can also learn something about elements ofDATATRIEVE. After you become familiar with the HELP program, type HELP at the DTR>prompt anytime during your session followed by the name of a topic. DATATRIEVE displays the appropriate text on your screen. Figure 4-2 shows the output when you use HELP to find out more about the keyword SHOW. DTR> HELP SHOWffi[O The SHOW stateMent is used to display the definitions of dOMainst recordst procedurest and tables stored in the data dictionarYt and inforMation concernin~ the state of various objects within Datatrieve. The forM of the stateMent is: SHOW obJect-l t obJect-2t obJect-3 ••• ",.here each 10bJect" is one of the follo . . . in~: SETS DOMAINS RECORDS PROCEDURES TABLES COLLECTIONS FIELDS READY CURRENT ALL DICTIONARY SPACE dOlTlain-nalTle reco rd-nalTle procedure-nalTle table-nalTle collection-nalTle DTR> Figure 4-2: The HELP SHOW screen 4.2 Using Guide Mode DATATRIEVE offers another type of help in Guide mode. Guide mode is useful when you are just learning DATATRIEVE, because it prompts you with a choice of entries that are correct. Guide mode works only on DIGITAL video display terminals. If you have a hardcopy terminal and enter a request for Guide mode, DATATRIEVE displays an error message on your terminal and returns you to DATATRIEVE command level (indicated by the DTR> prompt). To invoke Guide mode, enter: DTR> SET GUIDEffi[O 4-2 HELP and Guide Mode: Quick-Reference Section November 1987 The best way to see how Guide mode works is to use it. Guide mode completes keywords after you have typed only enough letters to uniquely identify them. For example, if you want to enter the keyword READY, you can type R, press the space bar, and Guide mode completes the word for you. If you type RE, REA, and so on, DATATRIEVE also completes the word as READY. Be careful that the second letter of the command does not duplicate the first letter of your next word, however. Suppose you want to READY the domain EMPLOYEES. If you type R, a space, then E, Guide mode reads the E as the second letter in READY instead of the first E in EMPLOYEES. You must type RE, a space, and then the E of EMPLOYEES. When you enter SET GUIDE and press RETURN, DATATRIEVE clears the terminal screen and prompts you to enter a command or type a question mark (?) for help. If you request help, DATATRIEVE displays all the possible words you can currently use. Throughout, Guide mode prompts you for the next part of your entry, including spaces, quotation marks, and carriage returns. Not all options are acceptable in Guide mode, but you can find out which ones are at any time by typing a question mark (?), and DATATRIEVE displays all the acceptable alternatives. DATATRIEVE displays an error message if the entry you try is not allowed. You can stop Guide mode by typing LEAVE. DATATRIEVE then displays a message on your terminal and returns you to DATATRIEVE command level (indicated by the DTR> prompt): \ ) LEA 1.1 Effirn You're on your own now. Good lucK! DTR> Although Guide mode is primarily a training tool, you may also find it useful to save keystrokes while typing. Experiment with it, and see the results you get. You can then judge how to use Guide mode to your advantage. \ ) ) November 1987 HELP and Guide Mode: Quick-Reference Section 4-3 \ ) Storing Data 5 This chapter shows you how to add new records to a data file using the STORE statement. 5.1 Preparing a Domain for Storing Data To store new records in a data file, you must ready the domain for WRITE or EXTEND access. With the WRITE command you can store, read, erase, and change records. With the EXTEND command you can only store records. The examples in this chapter use the PERSONNEL domain readied for WRITE access: "J DTR> READY PERSONNEL WRITEffili) DTR>- The DTR> prompt indicates that DATATRIEVE has readied the domain. Verify the type of access by entering: DTR>- SHOW READYffili) Read}' dOfrlains: PERSONNEL: RMS INDEXEDt PROTECTED WRITE DTR> The phrase PROTECTED WRITE confirms that you have write access to the PERSONNEL domain. You can now store records with the STORE statement. ) November 1987 5-1 5.2 Using the STORE Statement To add new records to a data file, use the STORE statement. DATATRIEVE immediately prompts you for the value of each elementary field in the new record. To store a new record in the PERSONNEL domain, type: DTR) STORE PERSONNELffirn Enter ID: 87ll22ffirn En t e r EM PLOYEE_STATUS: E~-{ PER I ENCEDffirn En t e r FIRST_NAME: MARTYffirn En t e r LAST _NAME: K ELLEYffirn Enter DEPT: T32ffirn Enter START_DATE: 2G-AUG-198Gffirn En t e r SALARY: 18750ffirn Enter SUP_ID: 87289ffirn DTR) Storing a record gives you an opportunity to observe several DATATRIEVE features you have not encountered before. Because DATATRIEVE is case sensitive in certain circumstances, you should make a habit of using all uppercase letters. Note that DATATRIEVE displays a date in the format you specify in the record definition, not in the format you use when you store the date. In the previous example you entered the date as 26-AUG-1986. You could also have entered it as 08-26-86. In either case, DATATRIEVE displays the date as 26-Aug-1986. Similarly, the record definition determines the format for the SALARY field. You enter the salary without a dollar sign. The record definition determines the form the field takes as output. The PERSONNEL-REC specifies that the dollar sign be printed. If you did the preceding example using your own PERSONNEL database, you actually added this employee to your file. 5.3 Preventing a STORE Statement from Taking Effect If you start to enter a STORE statement but then decide you want to cancel it, press CTRL/Z at any point before you finish creating or modifying the record. DTR) STORE PERSONNELffirn Enter ID: 07391ffirn Enter EMPLOYEE_STATUS: TRAINEE ffirn Enter FIRST_NAME: CHARLEYffirn En t e r LAST _NAME: ,. Z Execution terMinated by operator DTR) 5-2 Storing Data November 1987 ) 5.4 Creating a New Record Without Complete Information You can create a new record, even though all the necessary information is not yet available to you. In the following example, a person has been hired but her starting date, salary, and assignment are unknown. If you press a space or TAB key before pressing RETURN, DATATRIEVE sets the field to blank or zero, depending on the field definition. If you press RETURN without making any entry, DATATRIEVE continues to prompt you until you enter something. DTR) STORE PERSONNELffirn Enter ID: ffirn Enter ID: 123L15ffirn Enter EMPLOYEE_STATUS: TRA1NEEffiIT) Enter FIRST_NAME: HENR1ETTAffirn En t e r LAST _NAME: MI LLERffirn En t e r DEPT: @Jffirn En t e r S TAR T _ D ATE: @IDffirn En t e r SALARY: @IDffirn En t e r SUP _ I D: @IDffirn DTR) '. \ ;' If you did this example, the entry is now included in your PERSONNEL database, with blanks in the DEPT, START_DATE, and SALARY fields, and 00000 in the SUP_ID field. The PERSONNEL-REC record definition sets all these defaults. 5.5 Storing Two or More Records at a Time \ J / You can store more than one record at a time by using the REPEAT statement. Type REPEAT, the number of records you want to STORE, and the statement STORE PERSONNEL. DATATRIEVE prompts you for the values of each elementary field in each new record: DTR) REPEAT 2 STORE PERSONNELffirn Enter 1D: 75G39ffirn Enter EMPLOYEE_STATUS: TRA1NEEffirn Enter FIRST_NAME: M1KE(lli) Enter LAST_NAME: M1LLERffirn Enter DEPT: TLlLlffirn Enter START_DATE: G-FEB-1981ffirn En t e r SALARY: 1 G750ffiIT) Enter SUP_ID: 00012ffiIT) Enter ID: 75G40ffirn Enter STATUS: TRA1NEEffiIT) En t e r FIRST_NAME: BENffirn En t e r LAST_NAME: PUTNAMffirn Enter DEPT: TLlLlffirn Enter START_DATE: G-FEB-1981ffiIT) En t e r SALARY: 1 G500ffiIT) Enter SUP_ID: 00012ffiIT) DTR> Again, if you did this example, you have added these two employees to your PERSONNEL database. ) November 1987 Storing Data 5-3 When you are storing more than one record with a STORE command, each single record is stored as you complete the information for it and press the last RETURN before continuing with the next record. If you have requested DATATRIEVE to store a certain number of records and it turns out that you want to enter fewer than you had planned, you can stop the prompting for more entries with CTRL/Z. If you use CTRL/Z to terminate the entry of a record, it affects only that record. 5.6 Storing the Correct Type of Data in New Records The record definition specifies the type of data that you can store in each field of the record. When you create a new record, you must put the correct type of data in each of the fields. For instance, if the record definition requires a number, DATATRIEVE refuses to accept letters. If you try to enter the wrong type of data in a field, DATATRIEVE prompts you again for valid data. Look at the PERSONNEL-REC displayed in Section 3.3. To the right of each field name the record contains information describing that field. The PIC IS clause tells you the field's data type and its length. Xs indicate character data, and 9s indicate number data. The number in parentheses tells you the length of the field. For example, in the field SUP_ID, the PIC IS clause tells you that you can enter up to five numbers for SUP_ID. Sometimes the length of the field is described as a series of 9s or Xs, as in the DEPT field. The three Xs tell you that DEPT contains three characters. A summary of the type of data for the PERSONNEL-REC follows: • EMPLOYEE_STATUS, FIRST_NAME, LAST_NAME, and DEPT accept only character data. • START-DATE accepts only a date. • SALARY and SUP-ID accept only numbers. Sometimes records contain VALID IF clauses. For example, notice the clause VALID IF STATUS EQ "TRAINEE", "EXPERIENCED" in the field EMPLOYEE_STATUS. EQ is an expression meaning equal. The VALID IF clause specifies the choices that you can use for a particular field. In the EMPLOYEE_STATUS field the VALID IF clause tells you to enter either TRAINEE or EXPERIENCED with capital letters when storing information in that field. DATATRIEVE does not accept any other entry for the field EMPLOYEE_STATUS. 5-4 Storing Data November 1987 The next example shows the DATATRIEVE response to several of these kinds of entries: ) DTR> STORE PERSONNELffiIT) Enter ID: HAROLDffiIT) Non-digit in string "HAROLD", ignoring character<s> Re - en t e rID: 53402 OCBTI) Truncation during assignMent Re-enter ID: 34020ffiIT) Enter EMPLOYEE_STATUS: BEGINNERffiIT) Validation error for EMPLOYEE_STATUS Re-enter EMPLOYEE_STATUS: TYROffiIT) Validation error for EMPLOYEE_STATUS Re-enter EMPLOYEE_STATUS: TRAINEEffiIT) Enter FIRST_NAME: AZ Execution terMinated by operator DTR> The next chapter explains how to use the PRINT statement to retrieve data you have stored. ) \ ) ) November 1987 Storing Data 5-5 ~\ / Index < See LESS_THAN relational operator > See GREATER_THAN relational operator A I ,J Accessing domains, 2-4 to 2-5 ADT command, 3-6 See Also Application Design Tool AND Boolean operator, 6-5 Application Design Tool defining data with, 3-1 to 3-9 sample session, 3-4 to 3-8 ASCENDING sort key, 6-8 Assigning query names using the ADT command, 3-2 B BETWEEN relational operator, 6-4 BUT Boolean operator, 6-5 c ) Collections, 6-10 to 6-21 changing content of, 6-19 to 6-20 displaying, 6-11 to 6-12 erasing, 8-2 forming, 6-11 November 1987 Collections (Cont.) making new CURRENT from old, 6-14 to 6-15 naming, 6-15 to 6-17 releasing, 6-20 to 6-21 renaming, 6-18 to 6-19 SHOW command, 6-14 showing names of, 6-17 to 6-18 sorting, 6-12 to 6-14 CONTAINING relational operator, 6-4 CTRL/Z, 2-5,5-2 CURRENT in record selection expressions, 6-15 D Data dictionary creating, 3-9 placing definitions into, 3-8 to 3-9 Data types, 3-2 to 3-3 DEFINE DICTIONARY command, 3-9 DEFINE DOMAIN command, 3-9 DEFINE FILE command, 3-9 DEFINE RECORD command, 3-9 Defining data outside the Application Design Tool, 3-9 to 3-10 data with Application Design Tool, 3-1 to 3-9 DESCENDING sort key, 6-8 Index-1 Displaying DATATRIEVE objects, 2-4 See also SHOW command dictionary name, 2-2 Domains planning, 3-2 to 3-4 sample, 1-3 E Ending a DATATRIEVE session, 2-5 EQUAL relational operator, 6-4 Erasing data, 8-1 to 8-3 EXIT command, 2-5 Exiting an ADT session, 3-5 DATATRIEVE, 2-5 Information management, 1-1 Invoking an ADT session, 3-6 DATATRIEVE, 2-1 K Keys alternate index, 3-4 duplicate values, 3-4 primary index, 3-3 L LESS_EQUAL relational operator, 6-4 LESS_THAN relational operator, 6-4 F M Fields data types, 3-2 to 3-3 naming using the ADT command, 3-2 query names, 3-2 size, 3-3 Files indexed, 3-3 to 3-4, 7-7 sequential, 3-3 to 3-4 FIND statement, 6-11 FINISH command, 6-21 MODIFY statement ALL, 7-8 to 7-9 preventing, 7-5 to 7-6 Modifying data, 7-1 to 7-10 selected record, 7-4 to 7-6 G GREATER_EQUAL relational operator, 6-4 GREATER_THAN relational operator, 6-4 Guide Mode, 4-2, 4-3 H HELP command, 4-1,4-2 Indexed files, 3-3 to 3-4 ERASE statement with, 8-1 to 8-3 modifying, 7-6 to 7-8 Index-2 N Naming fields using the ADT command, 3-2 NOT Boolean operator, 6-5 NOT_EQUAL relational operator, 6-4 o OR Boolean operator, 6-5 p Primary index key, 3-3 PRINT statement, 6-1 creating reports with, 9-1 displaying data with, 6-5 to 6-10 Q Query names, 3-2 November 1987 R ~) / ) READY command, 2-4 to 2-5 Record selection expression, 6-2 to 6-5 Record stream, 6-1 displaying fields, 6-9 to 6-10 erasing, 8-2, 8-3 forming, 6-2 to 6-5 limiting, 6-2 to 6-6 modifying fields, 7-9 to 7-10 modifying records in, 7-9 to 7-10 sorting, 6-6 to 6-9 stopping display, 6-10 Records with missing values, 5-3 Relational operators, 6-4t RELEASE command, 6-20 Reports, 9-1 to 9-6 general features, 9-1 to 9-2 output to disk file, 9-5 output to line printer, 9-5 print list options, 9-5 saving specifications, 9-6 specification, 9-2 to 9-5 Retrieving data, 6-1 to 6-21 displaying all records, 6-1 RSE See Record selection expression Sequential files, 3-3 to 3-4 MODIFY statement with, 8-3 modifying, 7-1 to 7-6 SET GUIDE command, 4-2 SET statement (Report Writer) COLUMNS_PAGE, 9-3 SETUP.DTR command RSTS/E systems, 2-2 RSX systems, 2-2 SHOW ALL command, 2-3 SHOW DICTIONARY command, 2-2 SHOW DOMAINS command, 2-4 SHOW READY command, 2-4 SHOW RECORDS command, 2-4 Sort keys, 6-7 Starting an ADT session, 3-6 DATATRIEVE, 2-1 to 2-4 STORE statement, 5-1 cancelling, 5-2 data types, 5-4 REPEAT with, 5-3 T Terminology DATATRIEVE, 1-2 s SELECT statement, 7-1 to 7-5 forms of, 7-2 to 7-3 SHOW command with, 7-3 to 7-4 ) November 1987 Index-3 \ ) How to Order Additional Documentation ) If you live in: Call: or Write: New Hampshire, Alaska 603-884-6660 Digital Equipment Corp. P.O. Box CS2008 Nashua, NH 03061-2698 Continental USA, Puerto Rico, Hawaii 1-800-258-1710 Same as above. Canada (Ottawa-Hull) 613-234-7726 Digital Equipment Corp. 940 Belfast Road Ottawa, Ontario K1G 4C2 Attn: P&SG Business Manager or approved distributor Canada (British Columbia) 1-800-267-6146 Same as above. Canada (All other) 112-800-267-6146 Same as above. All other areas ) Digital Equipment Corp. Peripherals & Supplies Centers P&SG Business Manager c/o DIGITAL's local subsidiary Note: Place prepaid orders from Puerto Rico with the local DIGITAL subsidiary (phone 809-754-7575). Place internal orders with the Software Distribution Center, Digital Drive, Westminster, MA 01473-0471. ) Reader's Comments Introduction to DATATRIEVE-11 AA-X025A-TK Including: AD-X025A-T1 Please use this postage-paid form to comment on this manual. If you require a written reply to a software problem and are eligible to receive one under Software Performance Report (SPR) service, submit your comments on an SPR form. Thank you for your assistance. I rate this manual's: ) Accuracy (software works as manual says) Completeness (enough information) Clarity (easy to understand) Organization (structure of subject matter) Figures (useful) Examples (useful) Index (ability to find topic) Page layout (easy to find information) Excellent Good Fair Poor 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I would like to see more/less What I like best about this manual is ) What I like least about this manual is I found the following errors in this manual: Page Description ) Additional comments or suggestions to improve this manual: I am using Version _ _ _ of the software this manual describes. Name/Title Dept. Date Company ) / Mailing Address Phone -- Do Not Tear - Fold Here and Tape -------------------n-llr-------;~;;~--II if Mailed in the United States BUSINESS REPLY MAIL FIRST CLASS PERMIT NO. 33 MAYNARD MASS. POSTAGE WILL BE PAID BY ADDRESSEE DIGITAL EQUIPMENT CORPORATION Corporate User Publications-Spit Brook ZK01-3/J35 110 SPIT BROOK ROAD NASHUA, NH 03062-9987 11111'1111.1111 •• 1111111.11.1111.111 1111. I. 111.1111 I - Do Not Tear - Fold Here - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies