IBM Universe Retrieve
IBM Universe Retrieve
IBM Universe Retrieve
2A\retrieve\Front
February 21, 2008 11:52 am
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta
UniVerse
Guide to RetrieVe
Version 10.2
February, 2008
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Front
February 21, 2008 11:52 am
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
IBM Corporation
555 Bailey Avenue
San Jose, CA 95141
© Copyright International Business Machines Corporation 2006, 2008. All rights reserved.
AIX, DB2, DB2 Universal Database, Distributed Relational Database Architecture, NUMA-Q, OS/2, OS/390, and
OS/400, IBM Informix®, C-ISAM®, Foundation.2000 ™, IBM Informix® 4GL, IBM Informix® DataBlade® module,
Client SDK™, Cloudscape™, Cloudsync™, IBM Informix® Connect, IBM Informix® Driver for JDBC, Dynamic
Connect™, IBM Informix® Dynamic Scalable Architecture™ (DSA), IBM Informix® Dynamic Server™, IBM
Informix® Enterprise Gateway Manager (Enterprise Gateway Manager), IBM Informix® Extended Parallel Server™,
i.Financial Services™, J/Foundation™, MaxConnect™, Object Translator™, Red Brick® Decision Server™, IBM
Informix® SE, IBM Informix® SQL, InformiXML™, RedBack®, SystemBuilder™, U2™, UniData®, UniVerse®,
wIntegrate® are trademarks or registered trademarks of International Business Machines Corporation.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the
United States and other countries.
Windows, Windows NT, and Excel are either registered trademarks or trademarks of Microsoft Corporation in the United
States and/or other countries.
UNIX is a registered trademark in the United States and other countries licensed exclusively through X/Open Company
Limited.
Other company, product, and service names used in this publication may be trademarks or service marks of others.
Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
ii Guide to RetrieVe
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Table of
Contents
Table of Contents
Preface
Organization of This Manual . . . . . . . . . . . . . . . viii
Documentation Conventions. . . . . . . . . . . . . . . . ix
UniVerse Documentation . . . . . . . . . . . . . . . . . xi
Related Documentation . . . . . . . . . . . . . . . . . xiv
API Documentation . . . . . . . . . . . . . . . . . . xv
Chapter 1 Introduction
What Is RetrieVe? . . . . . . . . . . . . . . . . . . . 1-3
Using RetrieVe . . . . . . . . . . . . . . . . . . . . 1-4
The Sample Database . . . . . . . . . . . . . . . . . . 1-7
Installing the Sample Database . . . . . . . . . . . . . 1-7
Deinstalling the Sample Database . . . . . . . . . . . . 1-9
Multivalued Fields . . . . . . . . . . . . . . . . . . . 1-10
How Multivalued Fields Are Displayed . . . . . . . . . . 1-11
Making Simple Queries . . . . . . . . . . . . . . . . . 1-13
File Dictionaries . . . . . . . . . . . . . . . . . . 1-13
Sorting the Output . . . . . . . . . . . . . . . . . . . 1-16
Displaying Specific Fields . . . . . . . . . . . . . . . . 1-17
Customizing the Output . . . . . . . . . . . . . . . . . 1-20
Using Select Lists . . . . . . . . . . . . . . . . . . . 1-23
Printing Reports . . . . . . . . . . . . . . . . . . . 1-25
Making Queries Readable . . . . . . . . . . . . . . . . 1-27
RetrieVe and SQL . . . . . . . . . . . . . . . . . . . 1-28
iv Guide to RetrieVe
Creating a Sublist from a Select List. . . . . . . . . . . . 4-13
Manipulating Select Lists . . . . . . . . . . . . . . . 4-14
Other Things You Can Do with Saved Select Lists . . . . . . . 4-17
Table of Contents v
Chapter 7 Receiving an XML Document with RetrieVe
Receiving an XML Document through UniVerse BASIC . . . . . . 5-3
Defining Extraction Rules . . . . . . . . . . . . . . 5-3
Defining the XPath. . . . . . . . . . . . . . . . . 5-5
Extracting XML Data through UniVerse BASIC . . . . . . . 5-13
Displaying an XML Document through RetrieVe . . . . . . . 5-18
Displaying an XML Document through UniVerse SQL . . . . . 5-22
vi Guide to RetrieVe
C:\Program
Files\Adobe\FrameMaker8\UniVerse
Preface
This manual is for application developers and system administrators who want to
learn how to use RetrieVe commands to query their UniVerse databases.
vii
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Preface
2/21/08
Chapter 3, “Customizing Query Output,” explains how you can customize your
output using EVAL expressions, aggregate functions, breakpoints, field qualifiers,
and report qualifiers.
Chapter 4, “Creating and Using Select Lists,” discusses how to create and use select
lists.
Chapter 5, “Redirecting Output,” shows how to redirect output to files and tape
instead of to the terminal screen or printer.
Appendix A, “The Sample Database,” contains the file dictionaries for the 10 files
making up the sample database used in the examples in this document.
Documentation Conventions
This manual uses the following conventions:
Convention Usage
Courier Bold In examples, courier bold indicates characters that the user types
or keys the user presses (for example, <Return>).
itemA | itemB A vertical bar separating items indicates that you can choose
only one item. Do not type the vertical bar.
... Three periods indicate that more of the same type of item can
optionally follow.
ix
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Preface
2/21/08
Convention Usage
T Text mark. For example, the text mark ( T ) in the following string
delimits elements 4 and 5: 1F2S3V4T5
Documentation Conventions (Continued)
The following are also used:
x Guide to RetrieVe
C:\Program
Files\Adobe\FrameMaker8\UniVerse
UniVerse Documentation
UniVerse documentation includes the following:
UniVerse New Features Version 10.2: Describes enhancements and changes made
in the UniVerse 10.2 release for all UniVerse products.
UniVerse BASIC SQL Client Interface Guide: Describes how to use the BASIC
SQL Client Interface (BCI), an interface to UniVerse and non-UniVerse databases
from UniVerse BASIC. The BASIC SQL Client Interface uses ODBC-like function
calls to execute SQL statements on local or remote database servers such as
UniVerse, DB2, SYBASE, or INFORMIX. This book is for experienced SQL
programmers.
Using UniAdmin: Describes the UniAdmin tool, which enables you to configure
UniVerse, configure and manage servers and databases, and monitor UniVerse
performance and locks.
xi
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Preface
2/21/08
UniVerse User Reference: Contains reference pages for all UniVerse commands,
keywords, and user records, allowing experienced users to refer to syntax details
quickly.
Guide to RetrieVe: Describes RetrieVe, the UniVerse query language that lets users
select, sort, process, and display data in UniVerse files. This book is for users who
are familiar with UniVerse.
Guide to the UniVerse Editor: Describes in detail how to use the Editor, allowing
users to modify UniVerse files or programs. This book also includes reference pages
for all UniVerse Editor commands.
UniVerse NLS Guide: Describes how to use and manage UniVerse’s National
Language Support (NLS). This book is for users, programmers, and administrators.
UniVerse SQL User Guide: Describes how to use SQL functionality in UniVerse
applications. This book is for application developers who are familiar with UniVerse.
UniVerse SQL Reference: Contains reference pages for all SQL statements and
keywords, allowing experienced SQL users to refer to syntax details quickly. It
includes the complete UniVerse SQL grammar in Backus Naur Form (BNF).
Related Documentation
The following documentation is also available:
UniVerse GCI Guide: Describes how to use the General Calling Interface (GCI) to
call subroutines written in C, C++, or FORTRAN from BASIC programs. This book
is for experienced programmers who are familiar with UniVerse.
UniVerse ODBC Guide: Describes how to install and configure a UniVerse ODBC
server on a UniVerse host system. It also describes how to use UniVerse ODBC
Config and how to install, configure, and use UniVerse ODBC drivers on client
systems. This book is for experienced UniVerse developers who are familiar with
SQL and ODBC.
UniVerse Guide for Pick Users: Describes UniVerse for new UniVerse users familiar
with Pick-based systems.
xiii
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Preface
2/21/08
API Documentation
The following books document application programming interfaces (APIs) used for
developing client applications that connect to UniVerse and UniData servers.
Administrative Supplement for APIs: Introduces IBM’s seven common APIs, and
provides important information that developers using any of the common APIs will
need. It includes information about the UniRPC, the UCI Config Editor, the
ud_database file, and device licensing.
UCI Developer’s Guide: Describes how to use UCI (Uni Call Interface), an interface
to UniVerse and UniData databases from C-based client programs. UCI uses ODBC-
like function calls to execute SQL statements on local or remote UniVerse and
UniData servers. This book is for experienced SQL programmers.
IBM JDBC Driver for UniData and UniVerse: Describes UniJDBC, an interface to
UniData and UniVerse databases from JDBC applications. This book is for experi-
enced programmers and application developers who are familiar with UniData and
UniVerse, Java, JDBC, and who want to write JDBC applications that access these
databases.
InterCall Developer’s Guide: Describes how to use the InterCall API to access data
on UniVerse and UniData systems from external programs. This book is for
experienced programmers who are familiar with UniVerse or UniData.
UniObjects for Java Developer’s Guide: Describes UniObjects for Java, an interface
to UniVerse and UniData systems from Java. This book is for experienced
programmers and application developers who are familiar with UniVerse or UniData,
and with Java, and who want to write Java programs that access these databases.
xv
1Administering UniData on Windows NT or Windows 2000
0
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
Introduction
1
What Is RetrieVe? . . . . . . . . . . . . . . . . . . 1-3
Using RetrieVe . . . . . . . . . . . . . . . . . . . 1-4
The Sample Database . . . . . . . . . . . . . . . . . 1-7
Installing the Sample Database . . . . . . . . . . . . . 1-7
Deinstalling the Sample Database . . . . . . . . . . . . 1-9
Multivalued Fields . . . . . . . . . . . . . . . . . . 1-10
How Multivalued Fields Are Displayed . . . . . . . . . . 1-11
Making Simple Queries. . . . . . . . . . . . . . . . . 1-13
File Dictionaries . . . . . . . . . . . . . . . . . 1-13
Sorting the Output . . . . . . . . . . . . . . . . . . 1-16
Displaying Specific Fields . . . . . . . . . . . . . . . . 1-17
Customizing the Output . . . . . . . . . . . . . . . . 1-20
Using Select Lists . . . . . . . . . . . . . . . . . . 1-23
Printing Reports . . . . . . . . . . . . . . . . . . . 1-25
Making Queries Readable . . . . . . . . . . . . . . . . 1-27
RetrieVe and SQL . . . . . . . . . . . . . . . . . . 1-28
This chapter describes simple queries you can perform with RetrieVe, the UniVerse
query language that you can use to select, sort, and display information from your
UniVerse databases. This simple and understandable language allows application
developers to perform complex tasks easily while allowing end users to construct
queries with minimum knowledge.
What Is RetrieVe?
You can enter RetrieVe commands interactively, directly from your terminal, or
embed RetrieVe commands in application programs, procs, and paragraphs to access
data in UniVerse files and SQL tables. Although RetrieVe queries are part of
UniVerse, they provide additional capabilities unavailable in other UniVerse
commands. Using the RetrieVe syntax effectively, you can search the database to
extract a subset of data that meets certain qualifications. Once you have retrieved the
information you want, you can then use other (non-RetrieVe) UniVerse commands to
process the subset of data.
Suppose you run a retail operation and you want to track your inventory. To do this,
you maintain a UniVerse database that stores the product identification code,
description, wholesale cost, selling price, and the number in stock for each item you
carry. Using RetrieVe commands against this simple database, you could obtain a
variety of information vital to conducting your business. For example, you might ask
for a listing of:
Additionally, you can choose how this information is presented. Do you want it
displayed at your terminal or output on the printer? Would you prefer to have detailed
or summarized information? Would you like the listing sorted in some fashion, and
should the order be ascending or descending? For instance, you can tailor a report to
take advantage of a 132-character line printer, obtain total inventory value by product
line, or ask for a product listing arranged in order from highest to lowest markup.
1-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
Using RetrieVe
You can use RetrieVe to generate displays and reports from a database, entering your
queries as English-like sentences at the UniVerse prompt (>).
LIST is a common RetrieVe command that retrieves information from a file. Its
simplest form is the word LIST followed by a filename. To get a listing of a file called
INVENTORY.F, enter:
>LIST INVENTORY.F
Because you did not name any particular fields in the query, you got a default output.
Also, because you specified no selection criteria, you get all of the records in the file.
But what if you wanted to see only certain records, and only certain fields in those
records? As an example, you might ask to see the quantity on hand (QOH) and a
description for those products in inventory with a QOH greater than 100:
>LIST INVENTORY.F QOH DESCRIPTION WITH QOH > 100
LIST INVENTORY.F QOH DESCRIPTION WITH QOH > 100 08:55:12AM 31 May
1995 PAGE 1
INVENTORY.F QOH.. DESCRIPTION..............
To narrow your focus, you might refine the previous query to find all products with
a QOH over 100 and with a cost greater than $75:
>LIST INVENTORY.F DESCRIPTION QOH COST WITH QOH > 100
AND COST > $75
LIST INVENTORY.F DESCRIPTION QOH COST WITH QOH > 100 AND COST >
$75 09:02:03AM 31 May 1995 PAGE 1
INVENTORY.F DESCRIPTION............. QOH.. COST......
12 records listed.
The list is not in any particular order, so you again refine the command to present the
records in order by description:
>LIST INVENTORY.F DESCRIPTION QOH COST WITH QOH > 100
AND COST > $75 BY DESCRIPTION
LIST INVENTORY.F DESCRIPTION QOH COST WITH QOH > 100 AND COST >
$75 BY DESCRIPTION 09:03:43AM 31 May 1995 PAGE 1
INVENTORY.F DESCRIPTION.............. QOH.. COST......
12 records listed.
1-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
These examples (and the remaining examples in this manual) use a database repre-
senting the operative business data for a travelling circus. For a description of this
Circus database and the files it contains, see the next section and Appendix A, “The
Sample Database.”
Examples in this manual use the UniVerse file version of the database. Remember
that you can issue RetrieVe commands against SQL tables, and you can issue SQL
statements against UniVerse files. However, the results may look slightly different,
depending on which you use.
Command Action
MAKE.DEMO.FILES Creates and loads the Circus database files into the
current account. The files must not already exist in this
account. The file names have an .F suffix, and the
contents of the files are the same as those of the corre-
sponding .T tables.
1-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
Command Action
MAKE.DEMO.TABLES Creates and loads the Circus database table into the
current account, making the current user the owner of the
tables. The user must be a registered SQL user, the
account must be an SQL schema, and the tables must not
already exist in this schema. The resultant tables have a .T
suffix.
REMOVE.DEMO.TABLES Drops the Circus database tables from the current schema.
The user must be either a registered SQL user who is the
owner of the tables or a DBA.
Gernating and Removing Circus Database (Continued)
For example, to create and load the Circus database as UniVerse files into your
current account, enter:
>MAKE.DEMO.FILES
Compiling "ANIMALS".
TRANS ( LIVESTOCK.F , ANIMAL.ID , NAME , X )
Compiling "EQUIPMENT".
TRANS ( EQUIPMENT.F , EQUIP.CODE , DESCRIPTION , X )
Compiling "OP.NAME".
Note the warnings about the file names for CONCESSIONS and ENGAGEMENTS
being truncated. This applies only to their names within the operating system file
system, not to their UniVerse file names, so within UniVerse, you can still reference
them as CONCESSIONS.F and ENGAGEMENTS.F.
1-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
Multivalued Fields
Before getting deeper into the use of RetrieVe, you should be familiar with a unique
UniVerse attribute, multivalued fields. UniVerse uses a three-dimensional file
structure, called a nonfirst-normal-form data model, to store multiple values for a
field in a single record. Such fields are known as multivalued fields. Multivalued
fields enable a record to contain information that would otherwise be scattered
among several interrelated files.
UniVerse allows two or more multivalued fields to be defined in the file dictionary
as being associated with one another, in such a way that the first value of the first
multivalued field is associated with the first value of another field, the second value
of one with the second value of the other, and so forth. Such associations are useful
in situations where a group of multivalued fields forms an array or nested table within
a file. Each association has an association name.
The sample database uses many multivalued fields to store information such as
vaccination types and dates for each animal, information about the dependents of
each employee, and the staff and animals used in each act.
1-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
You can use association names in queries just as you do field names, so that you could
rephrase the previous query as follows:
>LIST INVENTORY.F DESCRIPTION ORDERS.ASSOC
For example, to count the records in the EQUIPMENT.F file, enter COUNT and the
filename:
>COUNT EQUIPMENT.F
62 records counted.
COUNT differs from LIST in that it displays only the total number of records, rather
than data from individual fields.
Note that when typing long commands that exceed a single line on your terminal, the
command automatically wraps to the next line. Do not press ENTER until you have
finished typing the command. If you want to force the start of a new line, type an
underscore (_) at the end of the current line and press ENTER. A plus sign (+)
appears at the beginning of the next line to indicate continuation.
File Dictionaries
Each UniVerse file has an associated file dictionary that describes each field in the
file. The kind of queries you can enter against a file and the output returned depend
on the file dictionary for the file.
Note: The following discussion assumes that you are familiar with UniVerse and that
you understand the concept of a file dictionary, the metadata that defines the
structure and content of a UniVerse data file.
Record IDs
The file dictionary generated by a CREATE.FILE command defines only the
record ID. The D-descriptor that defines the record ID is named @ID. A record ID
uniquely identifies each record in a file; it is sometimes referred to as field 0 and is
separated from the rest of the record’s data. Everything else has to be manually added
to the file dictionary later.
1-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
Thus, if you query a file having only this rudimentary dictionary, record IDs are all
you see displayed. For example, if the EQUIPMENT.F file had such a rudimentary
dictionary, a simple LIST command produces the following results:
>LIST EQUIPMENT.F
44
28
32
16
4
60
.
.
.
61 records listed.
Data Descriptors
But in reality the EQUIPMENT.F file, like all files in the Circus database, comes with
a complete set of data descriptors. These descriptors define all the fields in the file.
The dictionary also includes a special @ phrase that tells which fields to display if no
fields are named in the query. For example, the @ phrase for the EQUIPMENT.F file
specifies that the EQUIP.CODE, DESCRIPTION, and PURCHASE.DATE fields be
displayed by default. Asking for a listing that specifies no fields produces the
following output:
>LIST EQUIPMENT.F
A file dictionary can include a number of phrases that can be useful in RetrieVe
queries. In addition to the @ phrase, these include @LPTR, @REVISE, and user-
defined phrases.
You can also sort the output by any other field in the file. For example, to sort the
previous output in descending order by purchase date, enter:
>SORT EQUIPMENT.F BY.DSND PURCHASE.DATE
29 Merry-Go-Round 01/15/95
61 1992 Mack Truck Model 12/15/94
4500L
62 Calliope 10/28/94
33 Truck 588 R W J 12/16/93
17 Glamor Photo Stand 08/21/93
46 Computer 06/28/93
.
.
.
61 records listed.
1-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
To display specific fields in the file, enter their field names. For example, enter the
field name DESCRIPTION to display the description of products in the
INVENTORY.F file:
>LIST INVENTORY.F DESCRIPTION
Note that RetrieVe displays the record ID (the column heading of which is assigned
the file name by default—in this case, INVENTORY.F) even though you did not
name it in the query. Because the record ID uniquely identifies each record in a
UniVerse file, RetrieVe assumes you want to see it unless you indicate otherwise. In
UniVerse, record IDs are treated differently from other fields and can affect the
output of a query in specific ways. Refer to About Record IDs in Chapter 2,
“Constructing Queries,” for further information.
Most of the time, your query names specific fields rather than use the default. For
example, you might need to produce monthly inventory reports listing the record ID,
description, and quantity on hand. Because the record ID is included by default, you
need to name only the latter two fields in the query as follows:
>LIST INVENTORY.F DESCRIPTION QOH
If you ask for a multivalued field, each value in the field is output on a separate line.
For example, when you ask for a list of personnel and their dependents’ names and
dates of birth from the PERSONNEL.F file, the information for each dependent is
displayed as shown:
>LIST PERSONNEL.F NAME DEP.NAME DEP.DOB BY NAME
LIST PERSONNEL.F NAME DEP.NAME DEP.DOB BY NAME 10:58:25AM 31 May 1995 PAGE
1
PERSONNEL.F NAME..................... DEP.NAME.. DEP.DOB...
1-17
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
EVAL expressions can be used in a query to perform ad hoc calculations and produce
other values not directly obtainable from the database. For example, a record in the
inventory file contains price and cost fields, but not a profit field, so you have to
calculate the profit yourself, as shown in the following query:
>LIST INVENTORY.F PRICE COST EVAL "(PRICE - COST)" BY ITEM.CODE
You can also use aggregate functions to do such things as totalling a field, finding
averages, and obtaining the highest or lowest value in a field. For example, to total
the quantity on hand in inventory, enter:
>LIST INVENTORY.F DESCRIPTION TOTAL QOH BY DESCRIPTION
30 Balloons 77
1 Beer 127
38 Bird Seed 94
45 Bunting 199
9 Candy Selection 94
.
.
.
40 Ticket Stock 96
=====
5853
45 records listed.
1-19
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
You can also organize output by the values in one or more fields and produce
subtotals for each control break. In the INVENTORY.F file, items are categorized by
type, and you can ask for the total quantity on hand for each type:
>LIST INVENTORY.F BREAK.ON TYPE TOTAL QOH BY TYPE DET.SUP
5450
B 280
C 289
D 299
.
.
.
Z 223
=====
5853
45 records listed.
Finally, you can use field qualifiers to tailor the way in which RetrieVe displays an
output field, and report qualifiers to control the overall format of the output listing.
FMT is an example of a field qualifier and is frequently used to increase or decrease
the number of characters allowed for display of a field in the output.
For example, if you wanted to reduce the space allowed for displaying the description
in INVENTORY.F from 25 screen columns (characters) to 12, enter:
>LIST INVENTORY.F DESCRIPTION FMT 12T TOTAL QOH BY DESCRIPTION
30 Balloons 77
1 Beer 127
38 Bird Seed 94
45 Bunting 199
.
.
.
45 records listed.
Compare this output to that of two examples back, and notice that the
DESCRIPTION column is significantly narrower. CONV is another commonly used
field qualifier and is frequently used to mask field output, such as when you want to
add commas, monetary symbols, and other characters to a value. To insert a comma
every third integer position in QOH, you would use an MD, conversion code:
>LIST INVENTORY.F BREAK.ON TYPE TOTAL QOH CONV MD,
BY TYPE DET.SUP
LIST INVENTORY.F BREAK.ON TYPE TOTAL QOH CONV MD, BY TYPE DET.SUP
03:13:14PM 31 May 1995 PAGE 1
TYPE QOH..
B 280
C 289
D 299
F 82
.
.
.
X 131
Z 223
=====
5,853
45 records listed.
1-21
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
Select lists are commonly used to narrow a search by taking a file, selecting a subset
of records, and then further selecting or manipulating that subset. In the Circus
database, the LIVESTOCK.F file contains a field that categorizes each circus animal
by its use: Z = zoo animals, R = ride animals, and
P = petting animals. If you want to work with only those records belonging to zoo
animals, you could make a select list of all zoo animals by entering:
>SELECT LIVESTOCK.F WITH USE = Z
Now you have a select list that contains the record IDs of all the zoo animals, and you
can use this select list as you would a file. For example, you might want to list those
zoo animals whose country of origin is Canada. To do this, you enter the query as
though you were addressing the LIVESTOCK.F file. Because a select list is active
(as indicated by the >> prompt), the query uses it as a list of pointers to records in the
LIVESTOCK.F file.
>>LIST LIVESTOCK.F USE ORIGIN NAME DESCRIPTION
WITH ORIGIN = Canada
9 records listed.
The use of select lists is further covered in Chapter 4, “Creating and Using Select
Lists.”
1-23
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
Printing Reports
So far, the commands you have seen display their output on the screen. Alternatively,
you can redirect the output to a printer by using the LPTR keyword in the query. For
example, to list the INVENTORY.F file on the printer, enter:
>LIST INVENTORY.F LPTR
This query prints on logical print channel 0. To use another print channel, enter the
print channel number. For example, to print on print channel 10, enter:
>LIST INVENTORY.F LPTR 10
Just as you use the @ phrase for convenience when displaying data on the screen, it
might also be convenient to print field values without having to specifically name the
fields in your query. You could use the @ phrase for this, but because printers can fit
more fields on a line than a terminal, using the @ phrase for printing limits your flexi-
bility. Just as the @ phrase defines fields to be displayed when you do not name the
fields in the query, the @LPTR phrase defines the fields to be printed when the query
does not supply them.
Suppose you decide that the @ phrase for the INVENTORY.F file contains too many
fields to be displayed on a screen. Using the UniVerse ReVise facility or the UniVerse
Editor, you can redefine the @ phrase to include only the item code, cost, price, and
quantity on hand, as follows:
@
001 PH
002 ITEM.CODE COST PRICE QOH ID.SUP
You could then define the @LPTR phrase to include those fields originally in the
@ phrase as follows:
@LPTR
001 PH
002 ITEM.CODE ITEM.TYPE DESCRIPTION QOH COST PRICE VENDOR.CODE -
ORDER.QTY ID.SUP
If you do not specify an @LPTR phrase, the @ phrase is used to determine what
fields should be output to the printer. If neither an @LPTR phrase nor an @ phrase
exists for the file, RetrieVe only prints the record IDs.
Output can also be redirected to another file or to tape. These topics are covered in
Chapter 5, “Redirecting Output.”
The following query uses the words THE, FOR, and FILE without affecting the
meaning of the command:
>LIST THE ITEM.CODE DESCRIPTION PRICE FOR THE INVENTORY.F FILE
A ARE FILE
FOR INVISIBLE OF
1-25
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch1
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
Constructing Queries
2
Query Syntax . . . . . . . . . . . . . . . . . . . . 2-4
RetrieVe Verbs . . . . . . . . . . . . . . . . . . 2-5
About Record IDs . . . . . . . . . . . . . . . . . 2-7
Using Phrases . . . . . . . . . . . . . . . . . . 2-14
Selecting Records . . . . . . . . . . . . . . . . . . 2-18
Selecting Records by Record ID . . . . . . . . . . . . 2-18
Selecting Records by Sampling . . . . . . . . . . . . . 2-19
Selecting Records by String Comparisons . . . . . . . . . 2-21
Selecting Records by Field Values . . . . . . . . . . . . 2-21
Limiting Multivalued Output with WHEN . . . . . . . . . 2-37
Sorting Data . . . . . . . . . . . . . . . . . . . . 2-39
Sorting and Field Justification . . . . . . . . . . . . . 2-40
Sorting Records by Record IDs . . . . . . . . . . . . . 2-42
Sorting Records by Field Values . . . . . . . . . . . . 2-43
Sorting Data with Multivalues . . . . . . . . . . . . . 2-45
Getting an Internal View of Your Data . . . . . . . . . . . . 2-48
Query Syntax
Before you can use queries effectively, you need to know how they are structured.
RetrieVe queries contain the following elements:
Element Description
DICT Queries the dictionary of the file you specify in filename instead
of the data file. If specified, DICT must precede filename in the
query.
filename The name of the file. filename is required and can be almost
anywhere in the query.
records A list of record IDs that specifies the records on which the
query operates. Enclose the record IDs in single quotation
marks.
FROM list# A number, from 0 through 10, of an active select list that
contains record IDs. The query operates on those records whose
record IDs are in the select list.
selection.expression Specifies the conditions data in a record must meet in order for
the record to be selected for the query.
2-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
Element Description
output.specification Specifies either the names of the fields for output, or one or
more EVAL expressions. An output expression can also include
special keywords that direct the processing of field values for
output.
RetrieVe Verbs
To give you an overview of the things you can do with RetrieVe, here is a list of
RetrieVe verbs:
Verb Description
LIST Searches for and displays data from records in a file (see
Chapters 1 through 3).
LIST.LABEL Displays records in a format suitable for mailing labels and other
block listings (see Creating Mailing Labels in Chapter 3,
“Customizing Query Output.”).
Verb Description
SELECT Creates a list of records that meet specified selection criteria (see
Chapters 1, “Introduction,” and Chapter 4, “Creating and Using
Select Lists”).
SORT.LABEL Displays items in a format suitable for mailing labels and other
block listings (see Creating Mailing Labels in Chapter 3,
“Customizing Query Output”).
T.LOAD Copies records from tape to disk (see Loading T.DUMP Files
from Tape to Disk in Chapter 5, “Redirecting Output”).
RetrieVe Verbs (Continued)
Before getting into more detail about constructing RetrieVe queries, you need to
understand two important UniVerse concepts: record IDs and phrases.
2-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
The record ID value can be sequentially assigned numbers, used for the sole purpose
of satisfying the requirements of UniVerse file conventions, or they can be
meaningful data such as employee badge numbers, part numbers, or account
numbers. In any event, the record ID for each record must be unique, and it cannot
be a null value.
In the file dictionary there are potentially three types of entry associated with the
record ID: the @ID entry, one or more synonyms for the @ID entry, and an @KEY
phrase.
@ID Synonyms
@ID synonyms are optional entries you may find in some file dictionaries,
particularly in table dictionaries or in UniVerse files converted from tables through
the CONVERT.SQL utility. Defining an @ID synonym lets you refer to the record ID
by some name other than @ID. An @ID synonym definition, like the @ID entry, has
a field number of 0. In the Circus database, all files have @ID synonyms with names
like ITEM.CODE, BADGE.NUMBER, LOCATION.CODE, and so forth. Also,
defining an @ID synonym lets you specify a customized conversion code, column
heading, and formatting for displaying or printing the record ID. In the
PERSONNEL.F file, the @ID and @ID synonym definitions (in this example, the
synonym is BADGE.NO) appear in the dictionary as:
@ID
001 D Default record ID for RetrieVe
002 0
003
004 PERSONNEL.F
005 10L
006 S
BADGE.NO
001 D
002 0
003 MD0
004
005 5R
006 S
You can get the same effect by manually editing the @ID definition to look like the
@ID synonym definition.
LIST filename
2-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
and there is no @ phrase defined in the file dictionary, you get a list of record IDs. If
there is no @ID synonym, the values are headed and formatted according to the
definition of the @ID field in the dictionary. For example:
>LIST PERSONNEL.F
However, because dictionary files for the Circus database do contain @ID synonyms,
the list is formatted according to the definition of the synonym:
>LIST PERSONNEL.F
If you actually ask for @ID in a query, you may be confused by the output because
you get two columns of data. The first column is the @ID field (or its synonym field,
if one is defined) by default, and the second column is the @ID field you asked for:
>LIST PERSONNEL.F @ID
124 124
140 140
159 159
175 175
.
.
.
132 records listed.
Alternately, if you use the name of the @ID synonym (BADGE.NO in this example)
or @KEY, you again get two columns. This time they are formatted according to the
definition of the @ID synonym:
>LIST PERSONNEL.F BADGE.NO
124 124
140 140
159 159
175 175
191 191
.
.
.
132 records listed.
14
16
17
2
28
29
.
.
.
45 records listed.
Using ONLY is equivalent to the default list of record IDs displayed when both of the
following conditions are true:
2-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
Use the ID.SUP keyword to avoid listing the record IDs. For example, enter:
>LIST INVENTORY.F DESCRIPTION ID.SUP
In a table, a primary key (the SQL equivalent of a record ID) can comprise more than
one column (field), the only stipulation being that the combined values from all the
primary key columns must be unique for each row. As with multipart record IDs, the
values from all the primary key columns are packed into field 0 with a special
character separating the values. Such tables must always be updated using SQL state-
ments or a program, because you cannot enter the data into such a field using the
Editor or ReVise.
If you want to use SQL statements such as INSERT and UPDATE against UniVerse
files that are not tables and that contain multipart record IDs, create an @KEY phrase
in the file dictionary, using the following syntax:
@KEY
0001: PH
0002: key1 key2 [ keyn ] …
By default, the column names specified in field 2 of the @KEY phrase are separated
in the record ID by text marks, but you can specify another character as separator. To
do this, create an X-descriptor called @KEY_SEPARATOR, using the following
syntax:
@KEY_SEPARATOR
0001: X
0002: char
char is any single character that belongs to the 7-bit character set. It cannot be ASCII
NUL (CHAR(0)) or the null value.
2-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
This approach leads to some interesting displays that might be confusing. If you
request the @ID field in ENGAGEMENTS.F, either by default or directly in a query,
the LOCATION.CODE and DATE fields are concatenated and displayed in their raw
form with the date unconverted:
>LIST ENGAGEMENTS.F ADVANCE
CIAH001*10139 $6,975.00
CIAH001*10611 $7,709.00
WPHX001*10084 $6,134.00
CDFW001*9114
CIND001*9547
CMIL001*9195
EHAR001*9213
WSEA001*10280 $9,768.00
EATL001*9575
WSFO001*9364
WVGA001*10636 $9,403.00
CDFW001*10275 $12,068.00
CMIL001*10102 $3,416.00
CSPR001*9048
ENYC001*10565 $3,636.00
EPHI001*9814
CDFW001*10150 $11,971.00
.
.
.
252 records listed.
Using Phrases
Typing a long list of field names or expressions in every query can be tedious. To
avoid this, you can use phrases as a kind of shorthand. A phrase is stored in the file
dictionary and can contain any elements of a RetrieVe command except the verb and
file name.
If you want to refer to a group of fields by a single term—for example, use the term
MAILING.INFO to refer to the NAME, ADR1, ADR2, and ADR3 fields in the
PERSONNEL.F file—add the dictionary entry:
MAILING.INFO
001 PH
002 NAME ADR1 ADR2 ADR3
Then, whenever you want to include these fields in your output, enter:
A phrase can specify such things as a list of output field names, often-used
expressions, or associated fields. Probably the most commonly used phrase is the
@ phrase.
LIST filename
If all you get is a listing of record IDs, then no @ phrase was defined for the file.
2-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
Another way to check for the @ phrase is to list the file dictionary. To get a vertical
display of the dictionary entries, enter:
For example, to get a vertical display of the file dictionary for the EQUIPMENT.F
file, enter:
>LIST.ITEM DICT EQUIPMENT.F
@ID
001 D Default record ID for RetrieVe
002 0
004 EQUIPMENT.F
005 10L
006 S
EQUIP.CODE
001 D
002 0
005 5R
006 S
.
.
.
@
001 PH
002 ID.SUP EQUIP.CODE DESCRIPTION PURCHASE.DATE
@REVISE
001 PH
002 VENDOR.CODE VENDOR.REF DEPRECIATION DESCRIPTION COST
USE.LIFE TAX.LIFE VOLTS PURCHASE.DATE
In this case, the @ phrase lists the names of only three of the fields in the file:
002 ID.SUP EQUIP.CODE DESCRIPTION PURCHASE.DATE
These fields are listed by default if your query does not indicate which specific fields
you want to see. So if you simply enter:
LIST EQUIPMENT.F
you get a listing of these three fields even though you did not name them in the query.
Even if a file has an @ phrase defined, you can override it by specifying one or more
fields in your query. For example, the following query lists the record ID
(ITEM.CODE), quantity on hand, and price, and ignores the @ phrase entirely:
>LIST INVENTORY.F QOH PRICE
LIST INVENTORY.F QOH PRICE 12:03:32PM 31 May 1995 PAGE 1
INVENTORY.F QOH.. PRICE.....
14 154 $99.36
16 51 $45.78
17 140 $42.06
2 102 $75.83
28 174 $143.55
29 158 $76.51
.
.
.
45 records listed.
Besides the @ phrase just discussed, there are two other special phrases that you may
encounter in a file dictionary. If you look back at the file dictionary listing, you see
an @REVISE phrase, which is the default whenever you use a ReVise command
without specifying fields. There is also an @LPTR phrase, which specifies the
default list of fields to be used when output is sent to a printer.
You can define these phrases for a file when you create its file dictionary or you can
add it later. For example, the @ phrase for INVENTORY.F contains the item code,
type, description, cost, and price, and could have been inserted when the dictionary
was being built initially or added later when needed:
@
001 PH
002 ID.SUP ITEM.CODE TYPE DESCRIPTION COST PRICE
The ID.SUP at the beginning simply suppresses automatic display of the record ID,
since you have included ITEM.CODE as one of the fields.
2-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
Suppose that when you ask to see cost you most likely also want to see quantity on
hand and price. To avoid having to enter COST, QOH, and PRICE in your queries,
you could define a phrase in the file dictionary that encompasses all three and assign
it a label, say CQP:
CQP
001 PH
002 ID.SUP COST QOH PRICE
You could then use CQP as shorthand in a query to display the three fields, as follows:
>LIST INVENTORY.F CQP
Note: Naming a phrase in a query overrides the @ phrase, just as naming a field
does.
You can combine phrases and field names in the same query. For example, in addition
to CQP you could also ask for the item type:
>LIST INVENTORY.F CQP TYPE
Besides grouping fields, user-defined phrases in the file dictionary can also define
associations (two or more related multivalued fields).
Selecting Records
The simplest way to view records is to ask for all the records in the file. Usually, when
you look up information in the database, you do not want to see all the records in a
file. Instead, you would rather see a subset of the file—records that have certain
characteristics. For example, you might want to see a list of inventory items with
particular item codes, engagements scheduled for the fourth quarter, acts that last no
longer than 20 minutes, or every tenth vendor record.
Using RetrieVe, you can select records in any of the following ways:
By record ID
By sampling records
By finding records that meet certain criteria
By using select lists (refer to Chapters 1 and 4)
For example, to call up the record for item code 24 in INVENTORY.F, enter:
>LIST INVENTORY.F '24'
24 P Jerky $48.90
$64.55
1 records listed.
Because in some ways record IDs are like other fields, you can use any of the
relational operators (EQ, NE, GE, LT, LE, or GT) to select on record IDs.
2-17
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
If you want to retrieve several records, you can list several record IDs in the query,
as shown:
>LIST INVENTORY.F '23' '11' '14'
3 records listed.
If you want RetrieVe to prompt you for record IDs, use the INQUIRING keyword.
The following query asks you for the record IDs of the records you want to see, one
at a time:
>LIST INVENTORY.F INQUIRING
Record = 21
Record = <Return>
1 records listed.
>
To view another record, enter its record ID at the Record = prompt. Pressing
ENTER alone, as shown, ends the prompting and returns you to the UniVerse prompt
(>).
To sample the animal ID, name, and description of the first five records in the
LIVESTOCK.F file, use SAMPLE:
>LIST LIVESTOCK.F NAME DESCRIPTION SAMPLE 5
14 Zungeru Mongoose
2 Birnin Mink
28 Auchi Puma
29 Okene Lion
3 Argungu Otter
Notice that the previous example listed the first five records in LIVESTOCK.F. By
contrast, the following query, which samples every fifth record in the 87-record file,
lists 17 records (87 divided by 5):
>LIST LIVESTOCK.F NAME DESCRIPTION SAMPLED 5
3 Argungu Otter
60 Dabola Dhole
22 Koko Stoat
67 Sokolo Jaguar
18 Jebba Shetland
34 Baro Elephant
5 Sokoto Shetland
64 Morie Kinkajou
79 Zongo Cacomistle
15 Kontagora Shetland
42 Gashua Lion
68 Mopti Wolverine
84 Lisala Sable
32 Ekiti Shetland
63 Foula Shetland
39 Shendam Ferret
71 Bousso Shetland
2-19
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
SEARCH (or ESEARCH) selects records containing a specified string value and it is
useful when you do not know (or do not care) in what field the value is found. But if
you want to focus on a specific field, you need to select records by field values using
a WITH clause to define the selection criteria. For example, you might want to
modify the previous example and list only those inventory items with the text Frank
in the CONTACT field:
>LIST VENDORS.F COMPANY CONTACT WITH CONTACT LIKE ...Frank...
Note: The three periods, or ellipsis, (…) before and after Frank are wildcards,
indicating that you want to select all records in which the CONTACT field contains
the character string “Frank” regardless of whether other characters precede or
follow the string.
A selection expression retrieves only those records in which one or more specific
fields contain specific values. Once that has been done, the remainder of the query
can process the selected records. For example, you might want to find those records
with a contact name containing Frank, sort them alphabetically by company, and
print them—all in the same query:
>LIST VENDORS.F COMPANY CONTACT WITH CONTACT LIKE ...Frank...
BY COMPANY LPTR
A selection expression specifies the criteria that a field must meet in order for the
record to be processed. In this case WITH CONTACT LIKE ...Frank... is
the selection expression. A selection expression compares values from one or more
fields in the file with a value that you specify. The keyword WITH introduces a
selection expression, and relational operators compare the values. A selection
expression lets you work on a portion of the file without processing the file in its
entirety.
LIST PERSONNEL.F NAME DOB WITH DOB LT 01/01/50 09:18:28AM 31 May 1995 PAGE
1
PERSONNEL.F NAME..................... DOB.......
19 records listed.
2-21
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
The relational operator you use in a selection expression depends on the type of data
you are comparing: numeric or string.
Numeric A field containing strictly numeric data. Comparing their value takes into
account the concept of signed values.
Also, as seen in “Selecting Records Where Values Are Unknown” on page 30, you
can compare either type of data to nulls, that is, whether or not a field contains a null
value.
The following table shows which relational operators you can use for each type of
data.
Relational
Data Type Operator Synonym Description
EQ = Equal to
Relational Operators
Relational
Data Type Operator Synonym Description
LIST INVENTORY.F DESCRIPTION PRICE WITH PRICE > $100 11:10:40AM 31 May
1995 PAGE 1
INVENTORY.F DESCRIPTION.............. PRICE.....
28 Cookies $143.55
1 Beer $116.92
10 Franks $110.91
2-23
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
12 Mustard $135.45
22 Egg Rolls $159.85
25 Pretzels $126.47
31 Programs $126.85
38 Bird Seed $101.03
43 Sawdust $130.29
21 Sea Snails $100.29
5 Cola $149.10
11 records listed.
38 38 $84.19
1 records listed.
Use GT (or AFTER) and GE to find strings that come after a specified value
alphabetically and use LT (or BEFORE) or LE to find strings that come before a
specified value. For example, to get an alphabetical listing of all personnel with last
names that come after Miller, enter:
>LIST PERSONNEL.F NAME WITH NAME AFTER "Miller" BY NAME
LIST PERSONNEL.F NAME WITH NAME AFTER "Miller" BY NAME 10:01:22AM 31 May
1995 PAGE 1
PERSONNEL.F NAME.....................
54 Milosz, Charles
126 Milosz, James
29 Morse, Carol
192 Morse, Leonard
.
.
.
50 Young, Carol
114 Young, Joan
165 Young, Pamela
68 records listed.
As you saw in the example of searching for text string Frank in the CONTACT field,
you can use three periods as wildcard characters in the search value. As another
example of using wildcards, the two sets of three periods in the value in the following
query finds the text <space>CA<space> (California) anywhere in the ADR3 field
(including at the beginning or end):
>LIST LOCATIONS.F ADR3 WITH ADR3 LIKE "... CA ..."
LIST LOCATIONS.F ADR3 WITH ADR3 LIKE "... CA ..." 10:03:25AM 31 May 1995
PAGE 1
LOCATIONS.F ADR3.....................
3 records listed.
2-25
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
You can use wildcards in several different combinations to search for a string at the
beginning, end, or middle of a field, as shown in the following list:
LIST PERSONNEL.F NAME WITH NAME LIKE ...Ma... 10:04:38AM 31 May 1995 PAGE
1
PERSONNEL.F NAME.....................
15 records listed.
10 Martinez, Elizabeth
32 Mahoney, Elizabeth
2 records listed.
Use the UNLIKE (or NOT.MATCHING) keyword to determine if a string does not
contain a text value. For example, to select locations outside of California, enter:
>LIST LOCATIONS.F ADR3 WITH ADR3 NOT.MATCHING "... CA ..."
LIST LOCATIONS.F ADR3 WITH ADR3 NOT.MATCHING "... CA ..." 10:08:27AM 31 May
1995 PAGE 1
LOCATIONS.F ADR3.....................
The following list shows the character codes you can enter to test for different
character patterns:
Enter this
To test for a pattern of… character code…
2-27
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
Alphabetic characters are the letters A through Z; characters are any codable
character including spaces. When you are looking for a pattern of a specific number
of characters, precede the character code with the number of characters you are
searching for. For example, to find all personnel with names of exactly 10 characters
of any type, enter:
>LIST PERSONNEL.F NAME WITH NAME MATCHING '10X'
LIST PERSONNEL.F NAME WITH NAME MATCHING "10X" 10:10:09AM 31 May 1995 PAGE
1
PERSONNEL.F NAME.....................
70 Ford, Hope
25 Ford, Paul
71 Hill, Kate
40 Tuo, Chang
4 records listed.
Just as in searching for text within a field, you use wildcards (…) to specify that the
pattern can be found anywhere in the field. In the earlier example of selecting records
containing non-U.S. zip codes, you would enter:
Use the tilde (~) to indicate that you want the negative match of a pattern. For
example, to find all street addresses with no numbers, enter:
>LIST PERSONNEL.F BADGE.NO ADR1 WITH ADR1 MATCHING "~0N"
LIST PERSONNEL.F BADGE.NO ADR1 WITH ADR1 MATCHING "~0N" 10:18:17AM 31 May
1995 PAGE 1
PERSONNEL.F BADGE.NO ADR1.....................
2 records listed.
Testing for empty strings can be useful to find data that is known to have no value.
For example, you can use an empty string to find products with no price, as follows:
>LIST INVENTORY.F DESCRIPTION PRICE WITH PRICE = ""
LIST INVENTORY.F DESCRIPTION PRICE WITH PRICE = "" 10:45:19AM 31 May 1995
PAGE 1
INVENTORY.F DESCRIPTION.............. PRICE.....
17 Nachos
1 records listed.
Using an empty string can help you distinguish among products whose price is
unknown or null, products whose price is filled with zeros or blanks, and products
that have no price (empty string).
If you sort a field without first extracting the null values, the null values are included
in the output. A better strategy is to sort only those values that are not null. Use the
IS.NOT.NULL keyword to select records with field values that are other than null.
For example, to find all inventory items with a known price, enter:
>LIST INVENTORY.F DESCRIPTION PRICE WITH PRICE IS.NOT.NULL
2-29
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
Note that the value in the PRICE field for Nachos is an empty string, not null.
To find inventory items with unknown prices (that is, records with a null value in
PRICE), use the IS.NULL keyword as follows:
>LIST INVENTORY.F DESCRIPTION PRICE WITH PRICE IS.NULL
37 Dog Chow
42 Cheese Slices
2 records listed.
Note that, even though here the null values in PRICE appear as blanks, nulls may be
represented in other ways on other terminals and printers.
LIST PERSONNEL.F NAME WITH NAME SAID GUSTINO 10:57:58AM 31 May 1995 PAGE
1
PERSONNEL.F NAME.....................
2 records listed.
In order to be considered a match, the homonym and the value in the field must begin
with the same letter.
17 Nachos
1 records listed.
Nachos is listed because its price contains an empty string (meaning “no price”) and
an empty string is considered to be equal to 0. As another example, suppose you
wanted a listing of all equipment that has an estimated useful life greater than or equal
to its depreciation life:
>LIST EQUIPMENT.F DESCRIPTION USE.LIFE TAX.LIFE WITH USE.LIFE GE
TAX.LIFE
14 Coffee/cookies Stand 7 5
16 Wild West Photo Stand 5 3
17 Glamor Photo Stand 6 6
.
.
.
33 records listed.
Negation does not do anything you could not express in some other way, although it
does allow you to phrase a query in a more natural manner. For example, earlier when
you wanted to find any inventory items that had a price less than or equal to their cost,
you entered:
>LIST INVENTORY.F DESCRIPTION WITH PRICE LE COST
2-31
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
If you think of searching for items where price is not greater than cost, then it might
be more natural for you to phrase your query as follows:
>LIST INVENTORY.F DESCRIPTION WITH NOT PRICE GT COST
If you repeat the WITH keyword at the beginning of each selection expression, you
need not use the AND operator; multiple WITH clauses are connected with AND by
default.
To select inventory items that have both a quantity on hand of over 150 and a price
of less than $100, enter:
>LIST INVENTORY.F DESCRIPTION QOH PRICE WITH QOH > 150 AND
PRICE < $100
LIST INVENTORY.F DESCRIPTION QOH PRICE WITH QOH > 150 AND PRICE < $100
11:04:33AM 31 May 1995 PAGE 1
INVENTORY.F DESCRIPTION.............. QOH.. PRICE.....
13 records listed.
But if instead you want to see a list of inventory items that have a quantity on hand
of over 150 or a price of under $100, enter:
>LIST INVENTORY.F DESCRIPTION QOH PRICE WITH QOH > 150 OR
PRICE < $100
LIST INVENTORY.F DESCRIPTION QOH PRICE WITH QOH > 150 OR PRICE < $100
11:05:50AM 31 May 1995 PAGE 1
INVENTORY.F DESCRIPTION.............. QOH.. PRICE.....
You can use shortcuts in the following examples of compound selection expressions:
If the field name in the second selection expression is the same as the field
name in the first one, you can omit the second instance of the name. For
example, to find items with a quantity on hand greater than 50 but less than
75, enter:
>LIST INVENTORY.F WITH QOH GT 25 AND LT 50
instead of entering:
>LIST INVENTORY.F WITH QOH GT 25 AND QOH LT 50
You can omit OR in a selection expression which compares a field with two
different values. For example, the query:
>LIST INVENTORY.F DESCRIPTION QOH LT 75 OR GT 150
could be shortened to:
>LIST INVENTORY.F DESCRIPTION QOH LT 75 GT 150
2-33
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
In general, letting RetrieVe use a secondary index for record selection speeds up the
process, because RetrieVe can read a secondary index more quickly than it can scan
an entire file. RetrieVe uses a secondary index whenever possible, and the underlying
mechanism is largely transparent to the user.
To avoid this problem, you can require that the query not use the index.
Before you refer to an indexed field in selection criteria, you should first run
LIST.INDEX to determine whether an index is up-to-date or not yet built. For
example, assuming that the NAME field had a secondary index, the following display
indicates that this index is up-to-date:
>LIST.INDEX PERSONNEL.F NAME
File........... PERSONNEL.F
Indices........ 1 (0 A-type, 0 C-type, 1 D-type, 0 I-type, 0 S-type)
Index Updates.. Enabled, No updates pending
Index name Type Build Nulls In DICT S/M Just Unique Field
num/I-type
If the secondary index is not built or has not yet been updated, you need to specify
that the selection not use the secondary index. To do so, use the keyword NO.INDEX
to specify that the secondary index not be used.
For example, if you want to select records based on NAME, but you do not want
RetrieVe to use the secondary index on NAME, include NO.INDEX in your query:
>LIST PERSONNEL.F NAME WITH NAME LIKE T... NO.INDEX
LIST PERSONNEL.F NAME WITH NAME LIKE T... NO.INDEX 11:11:06AM 31 May 1995
PAGE 1
PERSONNEL.F NAME.....................
80 Torres, Stephen
38 Tucker, Alfred
89 Tanaka, Donna
41 Tucker, Joe
40 Tuo, Chang
137 Torres, Ernest
106 Tanaka, Joe
7 records listed.
18 records listed.
2-35
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
This listing displays all of the multivalues in the selected records. Usually, all you
want to see are only those vendors and order quantities that meet the selection
criterion of ORDER.QTY GE 900. To limit the display to just those values, use an
output limiter. Do not confuse an output limiter with a selection expression: a
selection expression selects records, an output limiter both selects records based on
a multivalued field and limits display of multivalues within the selected records.
An output limiter begins with the WHEN keyword instead of WITH. For example,
to display only those vendors and order quantities where ORDER.QTY is greater
than or equal to 900, use WHEN as follows:
>LIST INVENTORY.F DESCRIPTION VENDOR.CODE ORDER.QTY WHEN ORDER.QTY
GE 900
The output lists all records with multivalues greater than or equal to 900, and prints
a line for each such value, eliminating all order quantities (and their associated
vendor codes) that do not meet the criterion. Note that each multivalue listed is
counted in the total of 19 values in the summary line at the bottom of the report.
You can use WHEN with the LIST, SELECT, SORT, SSELECT, STAT, and SUM
commands.
2-37
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
Sorting Data
When you retrieve records from a file, records are listed in the order in which they
are stored in the file. For example, the following query lists records in the order they
physically exist in the INVENTORY.F file:
>LIST INVENTORY.F DESCRIPTION QOH COST
However, listing records in their physical order is almost never the best approach. A
major function of a query language is the ability to sort data before displaying it. You
can sort records by record IDs, by fields, or by some combination of both. In the
previous example, a likely order would be by description:
>LIST INVENTORY.F DESCRIPTION QOH COST BY DESCRIPTION
30 Balloons 77 $43.81
1 Beer 127 $76.92
38 Bird Seed 94 $84.19
.
.
.
45 records listed.
The UniVerse sort order or collating sequence is based on one of the following:
If NLS is disabled, UniVerse sorts characters by their byte value. If you enter data
with NLS enabled and a map of NONE, this is equivalent to the Unicode sort order.
If the data is mapped, for example, Korean, KSC5601 (double-byte), the byte order
of the character set determines the sort order.
For ways to customize the collating sequence, see the UniVerse NLS Guide.
You need to understand how fields are defined to get the sort order you want. The
justification of the field as specified in its dictionary entry determines the type of sort
performed when you specify a sort expression. For example, dates and most numeric
fields should be stored as right-justified to be sorted correctly. Nonnumeric (string)
fields generally should be left-justified in order to be sorted properly.
Much could be said about the sorting algorithm used, but an example is worth a
thousand words. So, to better understand sorting, take the following sample data (all
examples use the ASCII-7 character set):
FIELD.RJ FIELD.LJ FIELD.DEC...
2-39
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
Compare the differences between sorting on the left-justified string field versus the
right-justified string field:
FIELD.LJ FIELD.RJ
125 1A1
1250 5AB
12A 12A
1A1 125
5AB 1250
A1A A1A
A1C A1C
AA AA
AB1 AB1
AB11 AB11
AB20 AB20
CD20 CD20
As you can see, sorting on a left-justified field proceeds from left to right (that is, the
values are ordered by the leftmost position, and then within that by the next position
to the right, and so forth), and numerics come before alphabetics in the ASCII
collating sequence. In the example of the right-justified field, due to the mix of
numeric and nonnumeric characters, each substring is treated separately, with the
numeric characters sorted numerically and the nonnumeric characters sorted left to
right. Consequently 1xx comes before 5xx, which comes before 12x which comes
before 125, and so on, and 1250 comes before A1A because numbers precede
alphabetics.
-50.25
-10.00
-9.99
-2.25
-0.30
0.00
0.30
1.00
1.00
2.25
999.00
1000.00
As you would expect, right-justified numeric fields are sorted in what might be called
arithmetic order, because negative values are taken into consideration. Thus, –50.25
comes before –10.00 in the sort order because –50 is smaller than –10.
Because the record ID is defined by default as being left justified, the order is not
quite what you might expect. In this case, it would be better to use the @ID synonym
(ITEM.CODE) to get the order you wanted.
You could have used a LIST command with a BY @ID phrase instead of SORT, or
added a superfluous BY @ID phrase to the previous query.
2-41
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
BY and BY.EXP both sort in ascending order; BY.DSND and BY.EXP.DSND both
sort in descending order. For example, to sort records in the PERSONNEL.F file in
ascending order by NAME, enter:
>LIST PERSONNEL.F NAME BY NAME ID.SUP
Anderson, Suzanne
Astin, Jocelyn
Bacon, Roger
Bailey, Cheryl
Bennett, Nicholas
Bowana, Keltu
Brooks, Mary
Burrows, Alan
.
.
.
132 records listed.
Note that to display the sort field, you have to specify its name twice, once in the
sort.expression and once in the output.specification.
To sort the same file in descending order of the NAME field, enter:
>LIST PERSONNEL.F NAME BY.DSND NAME ID.SUP
Young, Pamela
Young, Joan
Young, Carol
Yamaguchi, Mary
Wood, Donna
Wood, Debbie
Wilkins, Alan
Whitcomb, Stephanie
Weinstein, Henry
Weinberg, Jeffrey
Wang, Isabel
.
.
.
132 records listed.
You can sort on more than one field, and even specify ascending order on some and
a descending order on others. For example, to see a list of inventory, ordered by QOH
(ascending) and COST (descending), enter:
>LIST INVENTORY.F QOH COST DESCRIPTION BY QOH BY.DSND COST
As the output shows, the costs for the items having a quantity on hand of 71 are listed
in descending order; the same holds true for the costs of the two items with a quantity
on hand of 94.
You cannot simply list sort fields one after the other, as you do when specifying fields
to be displayed. You must precede each field name with either BY or BY.DSND.
2-43
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
For example, assume that you want to list all scheduled vaccinations for the livestock,
in order by date, so that you can mark them on your calendar. Scheduled dates are
stored in the multivalued field VAC.NEXT, and the type of vaccination is stored in
an associated multivalued field called VAC.TYPE. Sorting on VAC.NEXT without
exploding it produces a list of records sorted by the first date found in VAC.NEXT in
each record, rather than by all dates, as shown:
>LIST LIVESTOCK.F DESCRIPTION VAC.NEXT VAC.TYPE ID.SUP
BY VAC.NEXT
Shetland 06/03/95 R
09/21/96 P
04/07/96 L
Horse 06/05/95 R
08/27/96 P
08/03/96 L
Horse 06/08/95 R
01/21/95 P
02/07/96 L
Linsang 06/12/95 R
03/27/95 P
03/30/95 L
Ferret 06/16/95 R
.
.
.
87 records listed.
Ferret 05/22/95 L
Otter 05/24/95 L
Hyena 05/24/95 P
Civet 05/26/95 P
Shetland 06/02/95 P
Shetland 06/03/95 L
Shetland 06/03/95 R
.
.
.
87 records listed.
Note that each multivalue is displayed on a separate line, and all dates are in
ascending order. Any data from the singlevalued fields in the record is repeated in
each exploded pseudo-record.
As with singlevalued fields, you can also sort multivalued fields in descending order.
To do this, use the keyword BY.EXP.DSND. For example, to list the multivalued field
QOH from the INVENTORY.F file in descending order, enter:
>LIST INVENTORY.F QOH ITEM.CODE DESCRIPTION ID.SUP
BY.EXP.DSND QOH
5450 50 Soda
825 46 Corn Dogs
199 45 Bunting
197 26 Coffee
193 6 Ice Bags
186 39 Film
185 5 Cola
181 43 Sawdust
174 28 Cookies
174 19 Fried Clams
171 41 T-shirts
169 42 Cheese Slices
165 33 Elephant Chow
162 23 Sausages
158 29 Paper Plates
.
.
.
45 records listed.
2-45
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
LIST.ITEM presents this data unsorted, and SORT.ITEM orders the data by
record ID. LIST.ITEM and SORT.ITEM are handy when you want to look at the
“raw” data, just as it is internally stored, unconverted, and see the “hidden” character
codes that are used to separate multivalues and fields. They are also convenient for
getting a listing of a file dictionary in a more easily readable form. Because both
commands retrieve the entire record, you cannot specify individual fields. However,
you can include selection criteria, sort criteria, and headers and footers in the
command. Values in multivalued fields are shown with the value (and subvalue)
marks that separate them.
For example, if you used LIST.ITEM to look at certain fields in the INVENTORY.F
file, you would get the following output:
>LIST.ITEM INVENTORY.F BY ITEM.CODE WITH COST < $50
3
001 U
002 Imported Ale
003 83
004 1351
005 2013
006 152v139v207v14v157v206
007 600v200v500v400v800v400
4
001 J
002 Lemonade
003 153
004 1457
005 2025
006 93v199v21v48v161v222v204v72v128
007 600v300v100v500v600v700v200v200v200
.
.
.
If you compare this with the layout of the INVENTORY.F file, you see that the
record ID is shown as field 0. Following this are ITEM.TYPE (field 1),
DESCRIPTION (field 2), QOH (field 3), COST (field 4), PRICE (field 5),
VENDOR.CODE (field 6, a multivalued field), and ORDER.QTY (field 7, another
multivalued field). Notice that in the documentation a value mark is shown as v and
a subvalue mark is shown as s. How these and other system delimiters appear on a
terminal screen or printer depends on the type of terminal or printer and how it is
configured.
You can also use either LIST.ITEM or SORT.ITEM against the dictionary of a file,
as shown in the following example:
>LIST.ITEM DICT INVENTORY.F
@ID
001 D Default record ID for RetrieVe
002 0
004 INVENTORY.F
005 10L
006 S
ITEM.CODE
001 D
002 0
005 5R
006 S
TYPE
001 D
002 1
005 1L
006 S
2-47
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch2
2/21/08
DESCRIPTION
001 D
002 2
005 25T
006 S
QOH
001 D
002 3
005 5R
006 S
.
.
.
@REVISE
001 PH
002 TYPE DESCRIPTION QOH COST PRICE VENDOR.CODE ORDER.QTY
@
001 PH
002 ID.SUP ITEM.CODE TYPE DESCRIPTION COST PRICE
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
This chapter shows you how to control the way in which the output from a query is
displayed or printed.
An output specification identifies the information you want included in the output of
a query. The simplest form of output specification is a list of the individual fields to
be included in the query output. For example, to list the description, quantity on hand,
and cost for records in the INVENTORY.F file, enter the following:
If you do not include an output specification in the query, the fields from the
@ phrase (if any) in the file dictionary are displayed. If the file dictionary has no
@ phrase defined, only the record IDs are listed. Using an output specification allows
you to override the @ phrase (or the default record ID display when no @ phrase is
present).
Many of the earlier examples used an output specification to display particular fields,
rather than default to the fields named in the @ phrase. But output specifications are
designed for much more than this. Use an output specification, to do the following:
3-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
An I-descriptor defines a virtual field whose contents are derived from constants,
fields in the associated data file, or fields from other files. I-descriptors or I-type
expressions are evaluated every time the RetrieVe sentence referencing or containing
them is executed. The I-descriptor can contain field names, operators (arithmetic,
logical, or conditional), constants, variables, substring extraction expressions, the
TRANS function (for file translation), the TOTAL function, and UniVerse BASIC
functions and subroutines.
For example, you might want to show profit margin as part of your output, and
include an EVAL expression as shown:
>LIST INVENTORY.F PRICE COST EVAL "(((PRICE - COST)/
COST) * 100)" CONV MD2 BY ITEM.CODE
( ( ( PRICE - COST ) / COST ) * 100 )
LIST INVENTORY.F PRICE COST EVAL "(((PRICE - COST)/COST) * 100)" CONV MD2
BY ITEM.CODE 09:03:32PM 31 May 1995 PAGE 1
(((PRICE - COST)/COS
INVENTORY.F PRICE..... COST...... T) * 100)...........
UniVerse executes the EVAL expression and lists the result as a field in the output.
This result is not stored for later use. The CONV MD2 is a field qualifier that formats
the profit margin value appropriately; field qualifiers are discussed later in this
chapter.
There are three guidelines you must observe when creating EVAL expressions:
You can use an EVAL expression in a query anywhere you would use a field name,
and, in fact, an EVAL expression may be the output specification. For example, to see
what a 15% increase in price would look like, enter the following query:
>LIST INVENTORY.F DESCRIPTION ID.SUP EVAL "PRICE * 1.15"
BY DESCRIPTION
PRICE * 1.15
Balloons $74.06
Beer $134.46
Bird Seed $116.18
Bunting $24.76
.
.
.
45 records listed.
3-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
The display includes the result of the computation defined in the EVAL expression,
that is, the present prices multiplied by 115%. These newly calculated prices exist
only for the output of the query and are not stored in the file (or anywhere else).
Notice that the column heading for an EVAL expression is the expression itself; if
you want to change this heading to something else, you must use a COL.HDG field
qualifier. Refer to “Customizing Column Headings” on page 33 for a discussion of
COL.HDG.
You can also use EVAL expressions in selection and sort expressions. For example,
to list only those items whose newly calculated price is now higher than $150, you
could use an EVAL expression as the selection criterion:
>LIST INVENTORY.F DESCRIPTION ID.SUP EVAL "PRICE * 1.15"
BY DESCRIPTION WITH EVAL "PRICE * 1.15" > 150
PRICE * 1.15
PRICE * 1.15
Cola $171.47
Cookies $165.08
Egg Rolls $183.83
Mustard $155.77
4 records listed.
To sort the output in descending order by the newly calculated price, enter the sort
expression as an EVAL expression:
>LIST INVENTORY.F DESCRIPTION ID.SUP EVAL "PRICE * 1.15"
BY EVAL "PRICE * 1.15"
PRICE * 1.15
PRICE * 1.15
LIST INVENTORY.F DESCRIPTION ID.SUP EVAL "PRICE * 1.15" BY EVAL "PRICE *
1.15" 09:14:40AM 31 May 1995 PAGE 1
DESCRIPTION.............. PRICE * 1.15
Nachos $0.00
Taffy $17.14
Film $17.81
Elephant Chow $19.10
Imported Ale $23.15
Lemonade $23.29
Large Cat Chow $23.67
Bunting $24.76
.
.
.
45 records listed.
TRANS is a UniVerse BASIC function that returns the contents of a field or record
in a UniVerse file. A simplified form of its syntax looks like this:
filename is the name of the UniVerse file from which you want to access the data,
record.ID is an expression that is the source for the record IDs of the records to be
accessed, field# is the field you want to access, and control.code specifies what action
to take if the data is not found or is the null value. TRANS is more commonly used
in definitions in a file dictionary than in interactive queries, but is shown here in the
latter context to illustrate its use.
For example, the VENDORS.F file contains information about the suppliers from
whom the circus purchases its inventory. Although the INVENTORY.F file includes
the vendor codes of these suppliers, you might want to see the actual company names,
information which can be found only in the VENDORS.F file. To list all the items in
the INVENTORY.F file and include the company names of their suppliers from the
VENDORS.F file, enter:
>LIST INVENTORY.F DESCRIPTION ID.SUP EVAL "TRANS(VENDORS.F,
VENDOR.CODE, COMPANY, 'X')" FMT 25T BY DESCRIPTION
TRANS ( VENDORS.F , VENDOR.CODE , COMPANY , X )
LIST INVENTORY.F DESCRIPTION ID.SUP EVAL "TRANS(VENDORS.F, VENDOR.CODE,
COMPANY, "X")" FMT 25T BY DESCRIPTION 09:39:44AM 31 May 1995 PAGE 1
TRANS(VENDORS.F, VEN.....
DOR.CODE, COMPANY, '.....
DESCRIPTION.............. X')......................
3-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
.
.
Ticket Stock Sunrise Logistics
Platinum Promotions
45 records listed.
Essentially this query takes each record in the INVENTORY.F file, uses its
VENDOR.CODE field to find corresponding records in the VENDORS.F file (that
is, records that have a record ID value corresponding to each VENDOR.CODE
value), and extracts the value in the COMPANY field. The X control code specifies
that an empty string is to be returned if a corresponding record does not exist or its
COMPANY field is null. FMT 25 sets the size of the output field to 25 characters.
Note that the quotation marks you use within the TRANS function must differ from
the quotation marks you use to specify the EVAL expression (this is a requirement of
the UniVerse BASIC language).
You have just seen an example of translating one field from another file. Here’s an
example of translating multiple fields from a second file, asking for a list of all rides
(from the RIDES.F file) together with both the description and vendor code for all
the equipment (from the EQUIPMENT.F file) that goes with each ride:
>LIST RIDES.F
EVAL "TRANS(EQUIPMENT.F, EQUIP.CODE, DESCRIPTION, 'X')"
FMT 25T EVAL "TRANS(EQUIPMENT.F, EQUIP.CODE, VENDOR.CODE,
'X')"
TRANS ( EQUIPMENT.F , EQUIP.CODE , DESCRIPTION , X )
TRANS ( EQUIPMENT.F , EQUIP.CODE , VENDOR.CODE , X )
15 records listed.
Rather than translating just a few fields of data, you can translate the data in all the
fields (except for the record ID) in the second file by specifying @RECORD (or its
equivalent, –1) as the field. For example, if you want to list all the details about the
equipment for each ride, rather than just the description and cost, enter:
>LIST RIDES.F EVAL "TRANS(EQUIPMENT.F, EQUIP.CODE, @RECORD,
'X')" FMT 25T
TRANS ( EQUIPMENT.F , EQUIP.CODE , @RECORD , X )
1 207
133030182
G
Sausage-on-a-stick Stand
2109673
4
4
110
8277
189
908597064
E
Cooling System
7059165
4
7
110
7880
19
230353709
M
Subsidiary Tent Frame
5758161
6
5
440
8830
.
.
.
15 records listed.
Note that, unlike the standard detail listing, the fields in the second file are not
labelled, so you would have to be familiar enough with the file to know that the first
line is the vendor code, the second is the vendor reference code, the third is the
depreciation code, the fourth is the description, and so forth. Also note that the record
ID of the EQUIPMENT.F file is not automatically included as part of the data display,
because in UniVerse the record ID is not considered data.
3-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
ENUM ENUMERATE Counts and displays the total number of values for a
field.
As a simple example, if you want to know the average duration of all the acts you
currently stage, enter:
>LIST ACTS.F DESCRIPTION ID.SUP AVG DURATION BY DESCRIPTION
Aerial Extravaganza 5
Animals on Parade 6
Clownarama 11
Grande Finale 6
6 records listed.
Or perhaps you want to know the highest price charged for an item in inventory:
>LIST INVENTORY.F MAX PRICE DET.SUP
==========
$159.85
45 records listed.
Note that you must specify DET.SUP (Detail Suppress), or you get a listing showing
each individual inventory item and its price, followed by the highest value.
If you want to know how many different vendors you purchase each inventory item
from (without actually listing the vendor codes), enter:
>LIST INVENTORY.F BREAK.ON ITEM.CODE ENUM VENDOR.CODE DET.SUP
BY ITEM.CODE
1 9
2 2
3 6
4 9
5 8
6 4
.
.
.
43 5
44 1
45 2
================
221
45 records listed.
3-10
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
As another example, you might want to find what percentage of the whole each
inventory item represents in terms of quantity on hand:
>LIST INVENTORY.F DESCRIPTION ID.SUP QOH PCT QOH BY DESCRIPTION
Balloons 77 1.32
Beer 127 2.17
Bird Seed 94 1.61
Bunting 199 3.40
Candy Selection 94 1.61
Cheese Slices 169 2.89
.
.
.
T-shirts 171 2.92
Taffy 71 1.21
Ticket Stock 96 1.64
======
100.00
45 records listed.
The report lists a percentage value for each record in the file, and therefore the listing
shows that the quantity on hand for balloons represents 1.32% of the total inventory,
the quantity on hand for taffy represents 1.21% of the inventory, and so forth. Note
that if you want to actually show the quantity on hand, you must specify QOH twice
in the query: the first mention specifies that the field be listed, the second mention
identifies the field on which to calculate the percent. Also note that the total
percentage is automatically computed and displayed as part of the PCT function, but
the report does not list the total quantity on hand. Use the TOTAL field modifier to
list the total quantity as well. For example:
>LIST INVENTORY.F DESCRIPTION ID.SUP TOTAL QOH PCT QOH
BY DESCRIPTION
LIST INVENTORY.F DESCRIPTION ID.SUP TOTAL QOH PCT QOH BY DESCRIPTION
10:11:39AM 31 May 1995 PAGE 1
DESCRIPTION.............. QOH.. QOH...
Balloons 77 1.32
Beer 127 2.17
Bird Seed 94 1.61
Bunting 199 3.40
Candy Selection 94 1.61
Cheese Slices 169 2.89
Coffee 197 3.37
.
.
.
T-shirts 171 2.92
Taffy 71 1.21
Ticket Stock 96 1.64
===== ======
5853 100.00
45 records listed.
Notice that because TOTAL QOH is an output specification, it automatically lists the
field being totalled so you do not need to specify QOH a third time in order to have
it appear in the listing.
========
TOTALS 45
========
AVERAGES 7.5
========
COUNTS 6
6 records summed.
The SUM command is analogous to the TOTAL modifier, in that it totals a field.
Earlier, you asked for the TOTAL QOH and you got a detailed listing of inventory
items with a total QOH at the end. If you want only the total QOH, just enter:
>SUM INVENTORY.F QOH COST
===== ==========
TOTALS 5853 $2,394.82
45 records summed.
3-12
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
Note: If a multivalued field is named in a SUM phrase, all the values are added
together. For example, if you summed the multivalued field ORDER.QTY, you would
get a total of all the multivalues in the field:
>SUM INVENTORY.F ORDER.QTY
=========
TOTALS 115000
45 records summed.
When you want to organize a file by the content of a field and then produce a subtotal
each time the value of that field changes, use the BREAK.ON keyword and specify
a sort on that field.
As an example of using BREAK.ON, assume that you want to see the detail cost for
each inventory item along with the total advance per type. To obtain this, include both
a BREAK.ON and a BY (sort) on TYPE and perform a TOTAL calculation on COST:
>LIST INVENTORY.F BREAK.ON TYPE DESCRIPTION TOTAL COST
BY TYPE BY DESCRIPTION ID.SUP
==========
$2,394.82
45 records listed.
Note that a grand total is provided automatically at the end of the listing.
If the break field were multivalued, you would use BY.EXP instead of BY for the
sort. For example, to take the INVENTORY.F file and calculate the cost of the
quantity on hand by vendor, use a BY.EXP and a BREAK.ON on VENDOR.CODE:
>SORT INVENTORY.F BY.EXP VENDOR.CODE BREAK.ON VENDOR.CODE
DESCRIPTION TOTAL EVAL "COST * QOH" FMT 15R ID.SUP
COST * QOH
SORT INVENTORY.F BY.EXP VENDOR.CODE BREAK.ON VENDOR.CODE DESCRIPTION TOTAL
EVAL "COST * QOH" FMT 15R ID.SUP 03:13:35PM 31 May 1995 PAGE 1
VENDOR.CODE DESCRIPTION.............. COST * QOH.....
2 Coffee $5,222.47
** ---------------
2 $5,222.47
9 Sausages $6,190.02
** ---------------
9 $6,190.02
11 Handbills $6,588.12
** ---------------
11 $6,588.12
===============
$1,638,334.64
3-14
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
TOT: ==========
$2,394.82
45 records listed.
In addition to labelling the grand total, you can also label the subtotal lines, via the
text option in BREAK.ON. For example, to add the label "Type" to the previous
output, enter:
>LIST INVENTORY.F BREAK.ON "Type" TYPE DESCRIPTION
TOTAL COST BY TYPE BY DESCRIPTION ID.SUP
GRAND.TOTAL "TOT:"
Type ----------
C $114.16
TOT: ==========
$2,394.82
45 records listed.
Note that, when labelling grand totals and subtotals, the width of your text is deter-
mined by the number of characters allotted to the data in the first column, which in
the previous example was the four characters occupied by the column heading TYPE.
If your grand total or subtotal label exceeds that, it is truncated, unless you specify a
FMT field qualifier to extend the width of the column. Refer to “Formatting the
Output of Fields and EVAL Expressions” on page 26 for a discussion of formatting
output.
For example, if you want to label the subtotals "Total for Type:", you need to add
FMT 15L to the BREAK.ON phrase in the query:
>LIST INVENTORY.F BREAK.ON "Total for Type:" TYPE FMT 15L
DESCRIPTION TOTAL COST BY TYPE BY DESCRIPTION ID.SUP
GRAND.TOTAL "TOT:"
LIST INVENTORY.F BREAK.ON "Type" TYPE TOTAL COST BY TYPE GRAND TOTAL "TOT:"
DET.SUP 10:24:12am 31 May 1995 PAGE 1
TYPE COST......
B $72.21
C $114.16
D $157.83
F $103.80
G $69.48
J $14.57
3-16
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
K $171.13
M $256.37
N $197.59
O $151.71
P $184.56
Q $49.60
R $203.59
T $42.78
U $42.12
V $226.30
W $165.94
X $96.36
Z $74.72
$2,394.82
45 records listed.
When you use DET.SUP, any labels you have specified for breakpoints or grand total
are ignored, and the default output of record IDs is suppressed as well.
For example, if you want to know your total livestock investment, broken down by
use and origin, enter:
>SORT LIVESTOCK.F BY USE BY ORIGIN BREAK.ON USE BREAK.ON
ORIGIN TOTAL COST ID.SUP DET.SUP
SORT LIVESTOCK.F BY USE BY ORIGIN BREAK.ON USE BREAK.ON ORIGIN TOTAL COST
ID.SUP DET.SUP 03:29:03PM 31 May 1995 PAGE 1
USE ORIGIN...... COST........
P Austria $24,006.00
P Brazil $10,697.00
P England $18,427.00
P India $6,867.00
P Kenya $59,023.00
P Pound $6,340.00
P Tahiti $8,960.00
P $134,320.00
R Egypt $29,881.00
R England $61,536.00
R India $6,529.00
R $97,946.00
.
.
.
Z Peru $8,016.00
Z Russia $6,134.00
Z Siberia $10,985.00
Z Texas $16,516.00
Z Ukraine $13,807.00
Z $305,608.00
============
$537,874.00
87 records listed.
Note that you get an intermediate total for each country of origin, a major total for
each use, and a grand total.
For instance, in a previous example that listed the items purchased from each vendor,
several vendors supplied only one item apiece, and having both a detail line and a
breakpoint line is somewhat superfluous. One example of this is vendor 2, who
supplies only coffee, and so the detail line and the total line show the same
information:
2 Coffee $5,222.47
** ---------------
2 $5,222.47
If this happens often, you might want to suppress the printing of the detail line and
show only the breakpoint line where there is only one detail line for a specific
breakpoint value. To do this, use the D option of the BREAK.ON keyword as
follows:
>SORT INVENTORY.F BY.EXP VENDOR.CODE BREAK.ON "'D'"
VENDOR.CODE DESCRIPTION TOTAL EVAL "COST * QOH"
FMT 15R ID.SUP
COST * QOH
2 Coffee $5,222.47
9 Sausages $6,190.02
11 Handbills $6,588.12
3-18
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
---------------
12 $24,214.82
.
.
.
45 records listed.
Now there is only one output line for each of these vendors, and that is the breakpoint
line.
In rare instances, you may not want to display the field on which you are breaking,
perhaps for reasons of confidentiality. For example, if you wanted to produce a salary
survey report by department but wanted to hide the identity of the departments, you
could break on the department but use BREAK.SUP instead of BREAK.ON to
suppress the display of the department designation.
In still other cases, you may want to break on a field, but not produce subtotals. You
can do this by using the L option with the BREAK.ON keyword. The output skips a
line to indicate the breakpoint, but no text or totals appear on the line. For example,
to list the inventory items by vendor, break on a change in vendor, but not do any
totalling, enter:
>LIST INVENTORY.F BY.EXP VENDOR.CODE BREAK.ON "'L'"
VENDOR.CODE DESCRIPTION ID.SUP
2 Coffee
6 Dog Chow
9 Sausages
11 Handbills
12 Pretzels
12 Ice Cream, Various
Paging on Breakpoints
Use the P option inside the text of BREAK.ON to force reports to start a new page
with each breakpoint. For example, the following query produces a report that starts
on a new page with each break on VENDOR.CODE:
>LIST INVENTORY.F BREAK.ON "Vend Total 'P'" VENDOR.CODE
BY.EXP VENDOR.CODE TOTAL EVAL "COST * QOH"
GRAND.TOTAL "FINAL:" ID.SUP
LIST INVENTORY.F BREAK.ON "Vend Total "P"" VENDOR.CODE BY.EXP VENDOR.CODE
TOTAL EVAL "COST * QOH" GRAND.TOTAL "FINAL:" ID.SUP 11:45:07AM 31 May 1995
PAGE 1
VENDOR.CODE COST * QOH
2 $5,222.47
Vend Total ----------
2 $5,222.47
6 $12,623.16
Vend Total ----------
6 $12,623.16
3-20
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
For example, if you use the phrase TOTAL PRICE in a query, the form used to
display the total defaults to the form defined for PRICE. Likewise, in the previous
example, where an EVAL expression (COST * QOH) was used to calculate the total
value of quantity on hand by vendor, the output format of the result defaults to the
format of the COST field.
There are three field qualifiers that can be used to temporarily apply formatting and
conversion characteristics to a field:
FMT
CONV
DISPLAY.LIKE
Generally, formatting (FMT) is used to specify the width of a display column, the
type of justification, the format of numeric data, and masking and padding characters.
Conversion (CONV) applies any BASIC conversion code available to the ICONV
and OCONV functions; date and time conversions are typical examples.
DISPLAY.LIKE is used to set a field’s display characteristics to be the same as those
of another field.
3-22
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
Before getting into the details, there are three overall concepts that you should
understand about formatting and conversion:
There are many reasons for using FMT in a query. For one, you might want to
increase or decrease the width allowed for displaying a field so that it fits better on a
line. For example, if you ask for a listing of names and addresses from the
PERSONNEL.F file, you get a vertical listing because both fields are defined with a
format of 25T in the file dictionary and they cannot fit across the page:
>LIST PERSONNEL.F NAME ADR1 ADR2
PERSONNEL.F. 124
NAME........ Schultz, Mary Lou
ADR1........ 6520 Bomar Street
ADR2........ Happy TX 79042
.
.
.
132 records listed.
You can make them all fit horizontally by using FMT to shorten their output length:
>LIST PERSONNEL.F NAME FMT 18L ADR1 FMT 25L ADR2 FMT 22L
LIST PERSONNEL.F NAME FMT 18L ADR1 FMT 25L ADR2 FMT 22L ID.SUP 11:50:51AM
31 May 1995 PAGE 1
NAME.............. ADR1..................... ADR2..................
Because justification affects sorting, you might also use FMT to cause a left-justified
field to be sorted as though it were right-justified or vice versa. Thus in a situation
where a numeric field is defined as left-justified in the file dictionary, which would
cause some unexpected results if you tried to sort it, you would use a FMT qualifier
to right-justify it before sorting.
Another common use of FMT is to display EVAL results with appropriate scaling.
Because EVAL expressions are not defined in the file dictionary, the only FMT (or
CONV) specifications they have are either the default specifications or the ones you
supply in the query.
3-24
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
Dates are a good example of the use of CONV. Internally, all dates are stored as an
integer representing the number of days relative to Day 0 (in UniVerse, Day 0 is
December 31, 1967). When a date is retrieved from this field, it must be converted to
a conventional form that is recognizable to the user.
Generally, conversion codes are identical to those used in the ICONV and OCONV
functions of BASIC.
You can tell the type of conversion from the conversion code:
There are also codes for converting data stored as packed decimal, hexadecimal,
octal, and binary. Some typical conversions are shown in the following tables, but
you should experiment with various combinations to get a sense of what you can do
with CONV.
Date Conversions
A value of July 2, 1995 in the DATE field of the ENGAGEMENTS.F file is used as
the source value.
DQ Quarter 3
DYJ Year and day number within the year 1995 188
Date Conversions
Time Conversions
A value of 5 pm in the TIME field of the ENGAGEMENTS.F file is used as the
source value.
3-26
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
Numeric Conversions
Numeric conversions can be masked character (MC), masked decimal (MD),
formatting numbers, and so on.
Conversio
n Code Explanation Example
MD22 Allows two decimal positions, and scales the stored 5.3465 becomes .05
data by moving its decimal point two places to the
left.
1 $9,768.84
2 $6,725.88
3 $1,121.33
4 $2,229.21
.
.
.
45 records listed.
3-28
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
To correct this, specify a conversion of MD40 (four decimal places, with a scale of
0, which overrides the dictionary’s scale of 2):
>LIST INVENTORY.F PRICE COST EVAL "(PRICE - COST)/COST" CONV MD40
LIST INVENTORY.F PRICE COST EVAL "(PRICE - COST)/COST" CONV MD40 01:15:00PM
31 May 1995 PAGE 1
INVENTORY.F PRICE..... COST...... (PRICE - COST)/COST
As another example of the use of CONV, the LIST command in the following query
displays the DATE field in the ENGAGEMENTS.F file and then displays it again as
the day of the week in combined lowercase and uppercase format:
>LIST ENGAGEMENTS.F LOCATION.CODE DATE DATE CONV "DWAL"
BY LOCATION.CODE BY DATE ID.SUP
If a conversion code has been supplied for a field in its file dictionary definition, and
you want that conversion to be ignored (that is, you want to display the data without
conversion), include a CONV " " for that field in your query.
You can override either of these by using the COL.HDG field qualifier in your query.
For example, if the column heading for the COST field is defined by default as “Cost”
and you want to make it “Amount Paid” for this query only, enter:
>LIST INVENTORY.F DESCRIPTION QOH COST COL.HDG "Amount'L'Paid"
BY DESCRIPTION ID.SUP
Balloons 77 $43.81
Beer 127 $76.92
Bird Seed 94 $84.19
.
.
.
T-shirts 171 $49.60
Taffy 71 $11.64
Ticket Stock 96 $57.13
45 records listed.
The 'L' in the input specifies that the column heading is to be broken into two lines at
that point.
The column heading for a virtual field is the EVAL expression itself, which is
probably not what you really want as the heading. For example, if you include in a
query an EVAL expression that calculates the cost of each of the products on hand by
multiplying the quantity available by the cost, the output looks like this:
>LIST INVENTORY.F DESCRIPTION EVAL "COST * QOH"
BY DESCRIPTION ID.SUP
COST * QOH
3-30
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
Balloons $3,373.37
Beer $9,768.84
Bird Seed $7,913.86
Bunting $3,570.06
Candy Selection $5,776.30
Cheese Slices $14,907.49
.
.
.
T-shirts $8,481.60
Taffy $826.44
Ticket Stock $5,484.48
45 records listed.
To change the heading to read Reorder Cost, add a COL.HDG to the query:
>LIST INVENTORY.F DESCRIPTION EVAL "COST * QOH"
COL.HDG "Reorder Cost" BY DESCRIPTION ID.SUP
COST * QOH
Balloons $3,373.37
Beer $9,768.84
Bird Seed $7,913.86
Bunting $3,570.06
Candy Selection $5,776.30
Cheese Slices $14,907.49
.
.
.
T-shirts $8,481.60
Taffy $826.44
Ticket Stock $5,484.48
45 records listed.
Creating an Alias
The AS field qualifier specifies a synonym, or alias, for a field or virtual field. The
main reason for using it is to shorten what would otherwise be a cumbersomely long
name, as in the following situations:
A good example of how an alias saves typing is when you included an EVAL
expression in the query and you want to sort on the results produced by it. Without
an alias, sorting a report on the basis of an EVAL expression forces you to type the
EVAL expression twice:
>LIST INVENTORY.F PRICE COST EVAL "(PRICE - COST) * QOH"
BY.DSND EVAL "(PRICE - COST) * QOH"
( PRICE - COST ) * QOH
( PRICE - COST ) * QOH
LIST INVENTORY.F PRICE COST EVAL "(PRICE - COST) * QOH" BY.DSND EVAL
"(PRICE - COST) * QOH" 01:33:03PM 31 May 1995 PAGE 1
INVENTORY.F PRICE..... COST...... (PRICE-COST)*QOH
42 $88.21
37 $96.36
5 $149.10 $102.83 $8,559.95
28 $143.55 $98.32 $7,870.02
43 $130.29 $90.48 $7,205.61
31 $126.85 $79.78 $6,731.01
.
.
.
8 $14.90 $11.64 $231.46
44 $25.96 $23.60 $143.96
17 $28.61 $-4,005.40
45 records listed.
By assigning an alias to the first occurrence of the EVAL expression, you can use the
alias in place of the second occurrence:
>LIST INVENTORY.F PRICE COST EVAL "(PRICE - COST) * QOH" AS PROFIT
BY.DSND PROFIT
( PRICE - COST ) * QOH
LIST INVENTORY.F PRICE COST EVAL "(PRICE - COST) * QOH" AS PROFIT BY.DSND
PROFIT 01:38:05PM 31 May 1995 PAGE 1
INVENTORY.F PRICE..... COST...... (PRICE - COST) * QOH
42 $88.21
37 $96.36
5 $149.10 $102.83 $8,559.95
28 $143.55 $98.32 $7,870.02
43 $130.29 $90.48 $7,205.61
31 $126.85 $79.78 $6,731.01
.
.
.
45 records listed.
3-32
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
LIST PERSONNEL.F BY BADGE.NO WITH NAME LIKE T... VERT NAME DEP.NAME
02:17:24PM 31 May 1995 PAGE 1
PERSONNEL.F. 38
NAME........ Tucker, Alfred
DEP.NAME.... Isabel
. Nancy
PERSONNEL.F. 40
NAME........ Tuo, Chang
DEP.NAME....
PERSONNEL.F. 41
NAME........ Tucker, Joe
DEP.NAME.... Beverly
. Brenda
PERSONNEL.F. 80
NAME........ Torres, Stephen
DEP.NAME.... Patricia
. Cecilia
.
.
.
7 records listed.
LIST PERSONNEL.F BY BADGE.NO WITH NAME LIKE T... VERT NAME ASSOC
"DEP.ASSOC" DEP.NAME 02:19:59PM 31 May 1995 PAGE 1
PERSONNEL.F. 38
NAME..................... DEP.NAME..
Tucker, Alfred Isabel
Nancy
PERSONNEL.F. 40
NAME..................... DEP.NAME..
Tuo, Chang
PERSONNEL.F. 41
NAME..................... DEP.NAME..
Tucker, Joe Beverly
Brenda
PERSONNEL.F. 80
NAME..................... DEP.NAME..
Torres, Stephen Patricia
Cecilia
.
.
.
7 records listed.
ASSOC.WITH is similar, except that you use it to associate a field with a multivalued
field instead of an entire association.
3-34
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
Use the DISPLAY.LIKE field qualifier to set the characteristics of a field to those of
another field. For example, to display the COST field in the same way that the QOH
field is displayed, enter:
>LIST INVENTORY.F COST DISPLAY.LIKE QOH COL.HDG "Cost in Cents"
14 8078
16 3495
17 2861
28 9832
29 4873
.
.
.
45 records listed.
Because QOH has a default definition of MD0 (numeric field, no decimal places),
COST is also displayed as an integer, and so now the value 98.32 is displayed as 9832
cents, as the user-supplied column heading indicates.
GRAND.TOTAL GRAND-TOTAL Sets the text for a grand total line. Use
with BREAK.ON.
Report Qualifiers
3-36
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
If you do not like the standard header, you can use the HEADING report qualifier to
design your own. Besides supplying the text of the header, you can also include one
or more options that provide additional features. A full list is in the UniVerse User
Reference, but a few of the more commonly used ones include:
Option Description
G Inserts gaps in the format to spread the heading across the entire
width of the screen or page.
I[n] or R[n] Inserts the current record ID, left-justified, in a field of n spaces.
3-38
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
Here is one example of a customized report header, where you ask that the heading
be centered (C) on the page and that the time (T) be included:
>LIST INVENTORY.F SAMPLE 3 DESCRIPTION QOH
HEADING "Inventory On Hand 'C' 'T'"
Inventory On Hand 02:57:42PM 31 May 1995
INVENTORY.F DESCRIPTION.............. QOH..
You can make the heading more readable by inserting descriptive text to label
elements such as date and page number:
>LIST INVENTORY.F SAMPLE 3 DESCRIPTION QOH
HEADING "Inventory On Hand Date: 'D' Page 'P3'"
You may even want to omit the header entirely. To suppress the display or printing of
a header, use the HDR.SUP report qualifier as shown:
>LIST INVENTORY.F SAMPLE 3 DESCRIPTION QOH HDR.SUP
ITEM.CODE DESCRIPTION.............. QOH..
Footers, like headers, can also be customized and have options that are almost
identical to those for headers.
Because this produces a very wide report, which might not be readable on a small
screen, you could use a vertical orientation, as follows:
>LIST EQUIPMENT.F DESCRIPTION COST DEPRECIATION FMT 3L
COL.HDG "DEP" PURCHASE.DATE VERTICALLY
EQUIPMENT.F... 14
DESCRIPTION... Coffee/cookies Stand
COST.......... $67,521.49
DEP........... C
PURCHASE.DATE. 12/16/91
EQUIPMENT.F... 16
DESCRIPTION... Wild West Photo Stand
COST.......... $5,016.53
DEP........... D
PURCHASE.DATE. 08/22/92
EQUIPMENT.F... 17
DESCRIPTION... Glamor Photo Stand
COST.......... $41,324.40
3-40
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
DEP........... Z
PURCHASE.DATE. 08/21/93
.
.
.
61 records listed.
Associated fields in a vertical listing are shown on separate lines. In the following
example, ITEM.CODE and LEAD.TIME are both multivalued fields, and their
individual values are listed on separate lines:
>LIST VENDORS.F ITEM.CODE LEAD.TIME VERTICALLY
VENDORS.F. 159
ITEM.CODE LEAD.TIME
18 66
38 37
44 31
5 83
16 43
30 42
6 84
43 32
46
VENDORS.F. 175
ITEM.CODE LEAD.TIME
39 20
33 47
1 39
10 75
.
.
.
232 records listed.
As in other queries, you can select records to be processed by using a list of record
IDs, a select list, or a selection expression.
When you run LIST.LABEL or SORT.LABEL, you are prompted to enter the options
that define the label layout:
>LIST.LABEL.F VENDORS COMPANY ADR1 ADR2 ADR3 HDR.SUP NOPAGE
COUNT, ROWS, SKIP, INDENT, SIZE, SPACE [ ,C ] ?
Edge of paper
COUNT number of labels across
INDENT
61 45
Italian Environmental Quad City Automation
Circus Supply Division Circus Supply Division
SPACE
9360 Argonne Street 97 Arbor Street
Sweet ID 83562 Congruity PA 14729 SKIP
29 223
Houston Professionals Immediate Enterprises
Circus Supply Division Order Department ROWS
1690 Norfolk Street 7280 Preston Street
Acme WA 98220 Sans Souci SC 29677
SIZE
Label Formatting
Note: When printing labels, include the NOPAGE report qualifier because normally
you do not want the Press any key to continue... message to print at
the bottom of each page.
3-42
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch3
2/21/08
Option Description
INDENT The number of indented spaces from the left margin to the label.
C Do not print empty fields. (If you do not include C, empty fields are
printed as a series of blanks.)
Label Options
When you specify the label options, follow these guidelines to make sure that the
options you specify are compatible with the physical layout of your output device:
The SIZE option cannot exceed the page width (80 columns for most
terminals, and 80 or 132 columns for printers).
The total width specifications cannot exceed the width of the output device
(generally the printer). Use the following formula to compute the total
width:
INDENT + COUNT(SIZE + SPACE)
If you use NLS mode and want to print labels in languages with wide
characters that print as two display positions on a screen, such as Korean,
you must allow for this in your calculations. (Make similar calculations
when you plan column headings, footings, and data that you do not want to
wrap.) For more information about NLS, see the UniVerse NLS Guide.
Suppose that the mailing labels you want to produce by the previous query have the
following specifications:
Given these specifications, you would enter the following values in response to the
parameters prompt:
RetrieVe then asks you to enter the row header for each row. Because they are not
needed for this example, just press Enter after each prompt (or you could have
specified HDR.SUP in the original query, which would eliminate this series of
prompts).
29 223
Houston Professionals Immediate Enterprises
Circus Supply Division Order Department
1690 Norfolk Street 7280 Preston Street
Acme WA 98220 Sans Souci SC 29677
207 191
United Advisers Convenient Promotions
Order Department 3900 Brazos Street
1510 Rosewood Street Access OH 43901
Access OH 43901
3-44
3Administering UniData on Windows NT or Windows 2000
0
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
This chapter describes creating and using select lists, and introduces you to the
RetrieVe commands SELECT, SSELECT, and SEARCH (or ESEARCH). Chapter 2,
“Constructing Queries,” and Chapter 3, “Customizing Query Output,” discussed
how you can select records on the basis of record IDs, sampling, field values, and
comparing one field to another. Another way to select records is by using select lists.
A select list contains the record IDs of records that meet specified criteria. Select lists
can be used with RetrieVe commands, UniVerse BASIC programs, the UniVerse
Editor, ReVise, and other UniVerse utilities.
In programming terms, you can think of a select list as a string of pointers to records
in a file. Suppose you are working with a sales file containing information organized
by branch offices, and you are interested only in the branch offices in Australia. You
can create a select list made up of record IDs of those records relating to branch
offices in Australia. Then you can use one query to produce a report of the branch
offices sorted by the highest volume sales and another query to produce another
report listing the branch offices sorted by size. This procedure avoids reading the
entire sales file for each query.
4-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch4
2/21/08
You can have up to 11 active select lists (numbered 0 through 10) at one time. Unless
you specify that a number be assigned to the select list you are creating, the number
defaults to 0. If you assign a number, it can be a number from 1 through 10.
When a select list is available for use, it is called an active select list. Select list 0 is
unique in that it is available (active) only for the next command, and you must use it
then or the system deletes it. As you will see later, one option is to issue a SAVE.LIST
command which saves the select list under a name so that you can recall it later. A
select list numbered 1 through 10 is active until you issue a command that contains a
FROM n clause (where n is the number of the select list) or you terminate the current
session.
Returning to the Circus database, you could issue the following SELECT command
to create a select list containing the record IDs of all vendors in the 208 area code:
Because you have used SELECT, the output is in the form of a select list rather than
a display or printed report. Notice that the prompt changes to >> to indicate that
select list 0 is active and available for use. For instance, you could use the newly
created select list to print the names of the vendors in area code 208:
>>LIST VENDORS.F COMPANY
8 records listed.
To create other numbered select lists, you must assign them a number from 1 through
10 using the TO clause, as follows:
>SELECT ACTS.F TO 4
Assume that you want a list of all the companies from which you have purchased
equipment prior to 1990. You know that the EQUIPMENT.F file contains the vendor
code for each piece of equipment owned by the circus, and the VENDORS.F file
contains the company name of each vendor and has vendor code as its record ID. By
creating a select list of the vendor codes in the EQUIPMENT.F file, you can use that
select list as pointers to the matching records in the VENDORS.F file.
To save a field other than the record ID in a select list, use the SAVING keyword
followed by the name of the field whose contents you want to place in the select list.
To do this, first create a select list of the vendor codes from the records for equipment
purchased before 1990. To indicate that it is VENDOR.CODE you want to store in
the select list and not the record ID, you must include a SAVING clause:
4-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch4
2/21/08
To get a list of the company names and phone numbers from the VENDORS.F
records that correspond to the select list values, all you would have to do is enter:
>>LIST VENDORS.F COMPANY PHONE ID.SUP
15 records listed.
This command uses the active select list as a list of record IDs against the
VENDORS.F file and retrieves and lists the names and phone numbers from those
records. For a further discussion of using select lists as record IDs, refer to “Using
Select Lists as Record IDs” on page 12.
To produce a select list with only those multivalues equal to or greater than 900, you
need to use the BY.EXP keyword to explode the multivalues of ORDER.QTY along
with the WHEN clause:
Now if you use this select list against the VENDORS.F file, you will get a correct
listing:
>>LIST VENDORS.F COMPANY BY COMPANY ID.SUP
COMPANY..................
Acme Brothers
Advantage Selections
Amalgamated Academy
American International
Baltimore Energy
Beneficial Mart
Blue Selections
Boston Equipment
Chicago World
Columbus Interfaces
Columbus Interfaces
Detroit Stockists
Gray Merchandise
Green Producers
Philadelphia Stores
San Diego Promotions
San Francisco
Distributors
Toledo Energy
Twin Cities Resources
19 records listed.
An advantage of using SEARCH is that you do not have to know which field the
string is in—the SEARCH command tests all the fields (except for the record ID
field) for the string. However, a disadvantage is that with large records in large files,
SEARCH can be very slow and is not the most efficient way to find what you are
looking for. In many cases, SEARCH should be used only as a last resort. SEARCH,
like most selection processes, is case-sensitive.
4-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch4
2/21/08
For example, to search the PERSONNEL.F file for the string San, regardless of in
what fields it occurs, and create a select list of those records, enter:
>SEARCH PERSONNEL.F
STRING: San <Enter>
STRING: <Enter>
>>
Then, if you are interested in looking at only the name and address fields of the
records in which the string was found, you could follow with the command:
>>LIST PERSONNEL.F NAME ADR1 ADR2 ADR3
LIST PERSONNEL.F NAME ADR1 ADR2 ADR3 11:38:25AM 31 May 1995 PAGE 1
PERSONNEL.F. 152
NAME........ Hanson, Allen
ADR1........ 1260 San Jacinto Street
ADR2........ Beautiful PA 15009
ADR3........
PERSONNEL.F. 184
NAME........ Hill, Sandra
ADR1........ 840 Locke Street
ADR2........ Carefree AZ 85719
ADR3........
PERSONNEL.F. 58
NAME........ Sousa, Evelyn
ADR1........ 9610 Mcgowen Street
ADR2........ Sans Souci SC 29677
ADR3........
.
.
.
132 records listed.
SAVE.LIST listname
listname is the name by which the saved list can be recalled. The saved select lists are
stored in the &SAVEDLISTS& file in your account.
Then, later, if you wanted to use this list in a RetrieVe command, all you would have
to do is activate it with this syntax:
GET.LIST listname
Now you can use it, as if you had just created it.
For example, assume that you created the “vendors in area code 208” list and saved it:
Now when you want to work with vendors in area code 208, just activate this select
list:
>GET.LIST AREA.208
4-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch4
2/21/08
Many UniVerse commands can use or operate on a select list. Some of the more
common ones include:
If you wanted to select vendors in the 208 area code and then sort those records in
descending order by TERMS (so that the more lenient payment terms appear first),
you could enter:
>SELECT VENDORS.F WITH PHONE LIKE 208...
LIST VENDORS.F TERMS PHONE BY.DSND TERMS 11:55:16AM 31 May 1995 PAGE 1
VENDORS.F. TERMS..... PHONE.......
64 Net 40 208/290-5374
61 Net 30 208/748-6410
131 Net 30 208/850-1095
71 Net 25 208/693-8859
201 Net 25 208/423-2273
135 Net 25 208/730-7712
103 Net 25 208/776-9628
113 Net 20 208/730-4703
8 records listed.
Select lists can contain values other than record IDs or field values from a file. The
next subsection shows how you create a select list of file names for use by another
command.
Take another example, where you create a select list of vendor codes from the
EQUIPMENT.F file of vendors from whom you purchased equipment prior to 1990:
At this point, select list 0 contains the vendors from which you purchased all pre-
1990 equipment. Using that select list as a source of record IDs, you can now use that
select list against the VENDORS.F file to retrieve the company names and phone
numbers of those vendors as follows:
>>LIST VENDORS.F COMPANY PHONE BY COMPANY ID.SUP
LIST VENDORS.F COMPANY PHONE BY COMPANY ID.SUP 12:04:13PM 31 May 1995 PAGE
1
COMPANY.................. PHONE.......
15 records listed.
Note that Kwik Outlets appears twice because two items were purchased from them
prior to 1990.
4-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch4
2/21/08
You could, for example, create a select list with all file names in the VOC file that
start with the text UV and then use ANALYZE.FILE to analyze the contents of the
files in the list. The following example shows both steps:
>SELECT VOC WITH NAME LIKE UV...
29 Paper Plates
4 Lemonade
10 Franks
22 Egg Rolls
31 Programs
40 Ticket Stock
42 Cheese Slices
23 Sausages
6 Ice Bags
9 records listed.
Once you create a numbered select list and then refer to it in some subsequent
command, the select list is deleted. The only way to preserve a select list is to save it
using the SAVE.LIST command (refer to “Saving a Select List for Future Use” on
page 9).
For example, suppose you want to know how many vendors have a vendor code
greater than 100, then how many of those have a phone number with an area code of
208, and finally list this latter subgroup in descending order by terms:
>SELECT VENDORS.F WITH VENDOR.CODE GT 100
LIST VENDORS.F TERMS PHONE BY.DSND TERMS 12:13:41PM 31 May 1995 PAGE 1
VENDORS.F. TERMS..... PHONE.......
131 Net 30 208/850-1095
201 Net 25 208/423-2273
103 Net 25 208/776-9628
135 Net 25 208/730-7712
113 Net 20 208/730-4703
5 records listed.
4-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch4
2/21/08
First you created a select list of those vendors with a vendor code greater than 100
and then, from that list, you created a sublist of vendors in the 208 area code, and then
you listed those vendors in descending order by TERMS. The beauty of this is that
the second SELECT command operated on only those records contained in the first
select list, not on the entire VENDORS.F file. VENDORS.F is a relatively small file,
but you can appreciate the advantages of this when working with files containing
hundreds of thousands of records. The reason for the order of SELECTs is that doing
pattern matching (LIKE) is a slower process than doing a simple equality type
selection on the same number of records.
Several commands create sublists besides SELECT and SSELECT. One is the
NSELECT command, which creates a select sublist consisting only of those data
elements from the active select list that are not in a specified file. As an example,
assume that you have two INVENTORY files, INVENTORY.OLD and
INVENTORY.NEW, and you want a list of item descriptions of those items in
INVENTORY.NEW that are not in INVENTORY.OLD. To obtain this listing, you
would enter the following:
>SELECT INVENTORY.NEW
Another approach to doing the same thing would be to use LIST.DIFF, which
compares two saved lists and creates a third list of elements that were found in the
first select list but not in the second.
LIST.DIFF compares two saved select lists and generates a third select list
containing those elements in list 1 that are not in list 2.
LIST.INTER compares two saved select lists and creates a third select list
containing elements from the first select list that are also found in the second
select list and are not redundant.
LIST.UNION compares two saved select lists and creates a third list made
up of elements from the first select list followed by elements in the second
select list that do not appear in the first select list and are not redundant.
MERGE.LIST generates a list containing any one of these formats
(difference, intersection, or union).
There are a number of uses for these commands. For example, you might create two
select lists and save them. One select list contains the record IDs of all inventory
items with a QOH less than 100. The other select list represents those inventory items
with a price greater than $75.
>SELECT INVENTORY.F WITH QOH LT 100
Perhaps after using each of these saved lists separately in subsequent queries, you
then decide you want to see a list of those items that appear in both lists. To do this,
use the LIST.INTER command, specifying the first of the two lists to be compared.
You are asked for the name of the second list, and then for the name of the new list
that results from the comparison:
>LIST.INTER QOHL
WITH: PRICE
TO: MERGED
Now you can activate this new list, and use it:
>GET.LIST MERGED
2 records listed.
4-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch4
2/21/08
As another example, you could use the same two select lists to find out which
inventory items have a QOH of less than 100 but do not have a price greater than $75.
In this case, you use LIST.DIFF, which produces a select list of the elements in the
first list (QOH > 100) that are not in the second list (PRICE > $75):
>LIST.DIFF QOHL
WITH: PRICE
TO: DIFFERL
Balloons 77 $64.40
Candy Selection 94 $71.28
Crabcakes 87 $33.95
French Fries, Frozen 51 $45.78
Imported Ale 83 $20.13
Ketchup 71 $48.76
Onion Rings 61 $25.96
Popcorn 57 $50.54
Taffy 71 $14.90
Ticket Stock 96 $73.13
10 records listed.
LIST.UNION would generate a new select list that contains nonredundant elements
from both lists, for example, inventory items that have a QOH of less than 100, or a
price of more than $75, or both.
>LIST.UNION QOHL
WITH: PRICE
TO: UNIONL
Balloons 77 $64.40
Beer 127 $116.92
Bird Seed 94 $101.03
Candy Selection 94 $71.28
Cola 185 $149.10
Cookies 174 $143.55
Cotton Candy 102 $75.83
Crabcakes 87 $33.95
27 records listed.
CLEARSELECT
COPY.LIST
DELETE.LIST
EDIT.LIST
GET.LIST
SAVE.LIST
4-17
4Administering UniData on Windows NT or Windows 2000
0
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
Redirecting Output
5
Redirecting Output to a File . . . . . . . . . . . . . . . 5-3
Using the Record IDs of the Original File . . . . . . . . . 5-3
Using Different Record IDs in the New File . . . . . . . . . 5-5
Reformatting from Two or More File Sources . . . . . . . . 5-6
Reformatting Raw Data . . . . . . . . . . . . . . . 5-8
Querying a Reformatted File. . . . . . . . . . . . . . 5-9
Redirecting Output to Tape . . . . . . . . . . . . . . . 5-11
Loading T.DUMP Files from Tape to Disk . . . . . . . . . 5-12
All the queries presented thus far have directed their output to a terminal screen or
printer. You can also direct query output to another file or to a tape. To do this, use
the RetrieVe commands REFORMAT, SREFORMAT, and T.DUMP.
As one example of redirecting output, you might want to search the INVENTORY.F
file for all records with a cost greater than $70 and write those records to a new file
called INV.HICOST.
5-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch5
2/21/08
To write a query’s output to a new file, use the RetrieVe REFORMAT and
SREFORMAT commands. These commands are similar to the LIST and SORT
commands and have an almost identical syntax, except that they direct their output to
another file or to a tape instead of to a terminal screen or a printer. REFORMAT
processes your data, as does the LIST command, before writing the data to another
file or to tape. Any correlatives, conversions, and
I-descriptors defined in the file dictionary are applied to the records before they are
stored.
The new file can have the same record ID field as the original file, or it can be
different.
File name =
Note that the first field you name (in this case, @ID) in the command becomes the
record ID of the new file, and that the order in which you list the other fields deter-
mines the order of the fields in the new file. At the File name = prompt, enter the
name of the new file:
File name = INV.HICOST.F
Now that the new file has been created and populated, you can list it. Use LIST.ITEM
or SORT.ITEM instead of LIST or SORT, because the only entry in the file dictionary
at this point is @ID and using LIST or SORT would display only that one field. For
INV.HICOST.F, the command is:
>SORT.ITEM INV.HICOST.F
1
001 Beer
002 $76.92
003 $116.92
10
001 Franks
002 $99.92
003 $110.91
12
001 Mustard
002 $91.52
003 $135.45
14
001 Ice Cream, Various
5-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch5
2/21/08
002 $80.78
003 $99.36
.
.
.
Because the CREATE.FILE command creates a default file dictionary that has only
one field definition (@ID), the field names, formatting, or conversion codes from the
old file dictionary do not exist in this new file dictionary. Therefore, at some point,
you would have to edit the file dictionary for INV.HICOST.F, adding names, formats,
conversions, and so forth, for all the fields, as well as adding an @ phrase, I-
descriptors, and other embellishments (refer to “Querying a Reformatted File” on
page 9).
File name =
At the File name = prompt, enter the name of the new file, VEND.CO.F:
File name = VEND.CO.F
Now list the new file to make sure it contains what you expected. In the case of
VEND.CO.F, record ID is company name, and vendor code and terms are its two data
fields, as shown:
>SORT.ITEM VEND.CO.F
Accurate Surplus
001 3
002 Net 20
Acme Brothers
001 1
002 Net 30
Action Operators
001 2
002 Net 25
Adam Supplies
001 216
002 Net 20
Advantage Selections
001 5
002 Net 40
Affordable Merchandise
001 4
002 Net 20
.
.
.
5-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch5
2/21/08
File name =
Here, the TRANS function takes the location codes from the ENGAGEMENTS.F
file, finds the matching records in the LOCATIONS.F file, and for each record writes
the LOCATION.CODE value from the ENGAGEMENTS.F file and the NAME and
PHONE values from the LOCATIONS.F file into the new file. However, since
LOCATION.CODE is the record ID of the new file and all its values must be unique,
records with duplicate LOCATION.CODE values overwrite one another, so that the
result is only one record per site.
Now use LIST.ITEM or SORT.ITEM to list the new file. For PHONES.F, the
command is:
>SORT.ITEM PHONES.F
CCLE001
001 Cleveland Properties, Inc.
002 216/965-8787
CDET001
001 Detroit Properties, Inc.
002 313/774-4808
CDFW001
001 Dallas Properties, Inc.
002 214/869-3105
.
.
.
If you want to do this only for reformatting purposes and do not need to store a
synonym in the file dictionary, you can define them only for the duration of the
REFORMAT command. In such cases, you suppress unwanted conversions by using
CONV " ". For example, to suppress conversions defined for COST in
LIVESTOCK.F when reformatting the data, enter:
>REFORMAT LIVESTOCK.F …COST CONV ""…
Be careful here, because any field for which you do not provide a synonym or CONV
" " uses the dictionary definition by default.
5-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch5
2/21/08
The @ID entry is automatically listed, by default, and the output is sorted by @ID
because of the SORT verb. The only other field in the file is the phone number field,
and you refer to it as F1.
As another example, the INV.HICOST.F file created under “Creating the New File”
on page 3 contains four fields: the item code, description, cost, and price. Again, only
the record ID (item code) is defined in the file dictionary, so you would have to refer
to the other three fields as F1, F2, and F3 to list them. To use meaningful field names,
you have to recreate the applicable field definitions of the original file dictionary in
the new file dictionary.
If the new file is simply a subset of records from the original file (as would be the
case where INV.HICOST.F contained the entire record, not just the four fields), you
could use the UniVerse COPY command to copy all the definitions from the
INVENTORY.F dictionary to the INV.HICOST.F dictionary:
>COPY FROM DICT INVENTORY.F TO DICT INV.HICOST.F
On the other hand, if you specified that only certain fields are to be reformatted to the
new file, or if you rearranged the fields, you could still copy the old dictionary to the
new dictionary. However, you then need to edit the new dictionary manually to adjust
field 2 of the data descriptor entries so they properly reflect the new locations or
relative positions of the fields. Use ReVise or another appropriate editing tool such
as the UniVerse Editor (or vi on UNIX systems) to do this.
5-10
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch5
2/21/08
1. Attach the tape by using the ASSIGN command or the T.ATT command (a
BASIC program which actually issues an ASSIGN command):
2. >T.ATT MTU 001
3. Position the tape using T.FWD or some other tape positioning command.
4. Issue the T.DUMP command. For example, to copy records from
ENGAGEMENTS.F for dates after 1995 to Tape 1 in Pick tape format,
enter:
>T.DUMP ENGAGEMENTS.F WITH DATE > '12/31/95' MTU 001
PICK.FORMAT
5. After the copying is completed, release the tape drive from your exclusive
control by issuing an UNASSIGN command:
>UNASSIGN MTU 001
Alternately, to copy only the date, location, time, and advance fields for those same
records from ENGAGEMENTS.F to tape, you would attach a tape and then use a
REFORMAT (or SREFORMAT) command with an MTU keyword and enter TAPE
as the filename:
>REFORMAT ENGAGEMENTS.F WITH DATE > '12/31/95' DATE LOCATION
TIME ADVANCE DATE LOCATION TIME ADVANCE MTU 001 PICK.FORMAT
Once you have copied records to tape, you can just as easily load it back from tape to
disk by using the T.LOAD command.
1. Attach the tape unit on which the tape has been properly positioned:
>T.ATT MTU 001
2. If necessary, create the file into which the tape’s contents are to be loaded:
>CREATE.FILE INV.HICOST1.F 30
3. Issue a T.LOAD command to load records from tape to the file:
>T.LOAD INV.HICOST1.F MTU 001 PICK.FORMAT
4. After the loading is completed, release the tape drive:
>UNASSIGN MTU 001
You can use a selection expression with T.LOAD, but you cannot specify sorting. If
the file into which you are loading contains data, T.LOAD loads only those records
that do not already exist. To cause T.LOAD to overwrite all records, use the keyword
OVERWRITING.
5-12
5Administering UniData on Windows NT or Windows 2000
0
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
XML was developed by the World Wide Web Consortium (W3C), who describe
XML as:
The Extensible Markup Language (XML) is the universal format for struc-
tured documents and data on the Web.
An XML document consists of a set of tags that describe the structure of data. Unlike
HTML, you can write your own tags. You can use XML to describe any type of data
so that it is cross-platform and machine independent.
UniVerse enables you to receive and create XML documents, and process them
through UniBASIC, UniVerse SQL, or RetrieVe. In order to work with the XML
documents in UniVerse, you will need to know some key terms:
4-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
You can combine external DTDs with internal DTDs in an XML document, and you
can create DTDs in an XML document.
XML Schema
The structure of the XML document can also be defined using XMLSchema, which
is an XML-based alternative to the DTD. An XML Schema defines a class of XML
documents, including the structure, content and meaning of the XML document.
XML Schema is useful because it is written in XML and is extensible to future
additions. You can create schema with XML, and you can use schema to validate
XML. The XML Schema language can also be referred to as XML Schema
Definition (XSD).
For optimum exchange of data, you should try to ensure that your XML documents
are valid.
4-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
1. If you are the originator of the DTD or XML Schema, use RetrieVe to create
the DTD or XMLSchema.
If you are not the originator of the DTD or XML Schema, analyze the DTD
or XML Schema associated with the application to which you are sending
the XML file. Determine which of your dictionary attributes correspond to
the DTD or XML Schema elements. You can also refer to “Mapping to an
External Schema” on page 38 at the end of this section.
2. Create an XML mapping file, if necessary. The mapping file will enable
users to create many different forms of XML.
3. List the appropriate fields using the LIST command.
Mapping Modes
UniVerse supports three modes for mapping data to XML files. These modes are:
Attribute-centric
Element-centric
Mixed
Attribute-centric Mode
In the attribute-centric mode, which is the default mode, each record displayed in the
query statement becomes an XML element. The following rules apply to the record
fields:
This is the default mapping scheme. You can change the default by defining maps in
the &XML& directory.
4-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
Element-centric Mode
In the element-centric mode, as in the attribute-centric mode, each record becomes
an XML element. The following rules apply:
Specify that you want to use element-centric mapping by using the ELEMENTS
keyword in the RetrieVe statement. You can also define treated-as = “ELEMENT” in
the U2XMLOUT.map file, so that all XML will be created in element mode.
4-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
</CGA-MS>
</CGA-MV>
</STUDENT>
</ROOT>
STUDENT.... 987654321
Last Name.. Miller
First Name. Susan
Crs #..... GD. Course Name.... Term
EG110 C Engineering FA93
Principles
MA220 Calculus- I
PY100 B Introduction to
Psychology
EG140 B Fluid Mechanics SP94
EG240 B Circut Theory
MA221 Calculus - II
STUDENT.... 123456789
Last Name.. Martin
First Name. Sally
Crs #..... GD. Course Name.... Term
PY100 Introduction to SP94
Psychology
PE100 C Golf - I
2 records listed.
>
Notice that three of the GRADE fields are empty, while their associated values for
COURSE # and COURSE NAME are not.
4-10
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
<SEMESTER>SP94</SEMESTER>
<Courses_Taken>
<COURSE_NAME>Introduction to Psychology</COURSE_NAME>
<COURSE_GRD/>
<COURSE_NBR>PY100</COURSE_NBR>
<TEACHER>Masters</TEACHER>
</Courses_Taken>
<Courses_Taken>
<COURSE_NAME>Golf - I</COURSE_NAME>
<COURSE_GRD>C</COURSE_GRD>
<COURSE_NBR>PE100</COURSE_NBR>
<TEACHER>Fisher</TEACHER>
</Courses_Taken>
</Term>
</STUDENT>
</main>
>
4-12
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
<COURSE_NAME>Introduction to Psychology</COURSE_NAME>
<COURSE_NBR>PY100</COURSE_NBR>
<TEACHER>Masters</TEACHER>
</Courses_Taken>
<Courses_Taken>
<COURSE_NAME>Golf - I</COURSE_NAME>
<COURSE_GRD>C</COURSE_GRD>
<COURSE_NBR>PE100</COURSE_NBR>
<TEACHER>Fisher</TEACHER>
</Courses_Taken>
</Term>
</STUDENT>
</main>
>
Mixed Mode
In the mixed-mode, you create your own map file, where you specify which fields are
treated as attribute-centric and which fields are treated as element-centric.
Field-level mapping overrides the mode you specify in the RetrieVe statement.
Defining these settings in the mapping file eliminates the need to specify them in
each RetrieVe statement.
Options you specify in the RetrieVe statement override options defined in the
mapping file. Options defined in the mapping file override options defined in the
U2XMLOUT.map file.
<?XML version=”1.0”?>
<!--there can be multiple <U2xml:mapping> elements -->
<U2xml:mapping file=”file_name”
hidemv=”0”
hidems=”0”
hideroot=”0”
collapsemv=”0”
collapsems=”0”
emptyattribute=”0”
hastm=”yes” | “1”
matchelement=”0” |”1”
schematype=”ref”
targetnamespace=”targetURL”
xmlns:NAME=”URL”
field=”dictionary_display_name”
map-to=”name_in_xml_douniversec”
type=”MV” | “MS”
treated-as=”attribute” | “element”
root=”root_element_name”
record=”record_element_name”
association-mv=”mv_level_assoc_name”
association-ms=”ms_level_assoc_name”
format (or Fmt)= “format -pattern”..
conversion (or Conv)= “conversion code”
encode=”encoding characters”
/>
...
</U2xml-mapping>
The XML mapping file is, in itself, in XML format. There are three types of signif-
icant elements: the root element, the field element, and the association element.
4-14
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
The root Element – The root element describes the global options that
control different output formats, such as the schema type, targetNamespace,
hideroot, hidemv, and hidems. You can also use the root element to change
the default root element name, or the record element name. You should have
only one root element in the mapping file.
The field Element – UniVerse uses the field element to change the charac-
teristics of a particular field’s XML output attributes, such as the display
name, the format, or the conversion.
The association Element – UniVerse uses the association element to
change the display name of an association. By default, this name is the
association phrase name, together with “-MV” or “-MS.”
Distinguishing Elements
You can distinguish the root element from the field and association elements because
the root element does not define a field or association element.
Both the field element and the association element must have the file and field
attribute to define the file name and the field name in the file that has been processed.
Generally, the field name is a data-descriptor or I-descriptor defined in the dict file,
making it a field element. If the field name is an association phrase, it is an associ-
ation element.
Hideroot Attribute
The Hideroot attribute allows you to specify whether to create the entire XML
document or only a section of it. For example, using the SAMPLE keyword or other
conditional clauses. If Hideroot is set to 1, UniVerse only creates the record portion
of the XML document, it does not create a DTD or XMLSchema. The default value
is 0.
Hideroot=”1”/”0”
Hidemv Attribute
This attribute specifies whether to hide <MV> and </MV> tags for multivalued fields
belonging to an association in the generated XML document and in the associated
DTD or XML Schema. This parameter applies only if the XML document is created
in element mode.
Note: If the document is created in attribute mode, it is not possible to eliminate the
extra level of element tags.
Hidems Attribute
This attribute specifies whether to hide <MS> and </MS> tags for multivalued fields
belonging to an association in the generated XML document and in the associated
DTD or XML Schema. This parameter applies only if the XML document is created
in element mode.
Note: If the document is created in attribute mode, it is not possible to eliminate the
extra level of element tags.
4-16
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
Collapsemv Attribute
This attribute specifies whether to collapse <MV> and </MV> tags, using only one
set of these tags for multivalued fields belonging to an association in the generated
XML document and in the associated DTD or XMLSchema. This parameter applies
only if the XML document is created in element mode.
Collapsems Attribute
This attribute specifies whether to collapse <MS> and </MS> tags, using only one
set of these tags for multi-subvalued fields belonging to an association in the
generated XML document and in the associated DTD or XMLSchema. This
parameter applies only if the XML document is created in element mode.
Emptyattribute
This attribute determines how to display the empty attributes for multivalued fields
belonging to an association in the generated XML document and in the associated
DTD or XML Schema. This option can be specified in the U2XMLOUT.map file, or
in an individual mapping file.
Namespace Attributes
UniVerse provides the following attributes for defining namespaces:
xmlns:name-space-name=”URL”
targetnamespace=”URL”
If you define the targetnamespace and other explicit namespace definitions, UniVerse
checks if the explicitly defined namespace has the same URL as the targetnamespace.
If it does, UniVerse uses the namespace name to qualify the schema element, and the
XML document element name.
In this case, UniVerse does not qualify the schema element or the XML document
element.
4-18
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
>RUN BP XML4
XMLMAPPING=student.map ELEMENTS TARGETNAMESPACE=www.ibm.com
Options XMLMAPPING=student.map ELEMENTS
TARGETNAMESPACE=www.ibm.com
XML output
<?xml version="1.0" encoding="UTF-8"?>
<main
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="www.ibm.com">
<STUDENT>
<_ID>987654321</_ID>
<LNAME>Miller</LNAME>
<Term>
<SEMESTER>FA93</SEMESTER>
<Courses_Taken>
<COURSE_GRD>C</COURSE_GRD>
<COURSE_NAME>Engineering Principles</COURSE_NAME>
<COURSE_NBR>EG110</COURSE_NBR>
</Courses_Taken>
<Courses_Taken>
<COURSE_GRD/>
<COURSE_NAME>Calculus- I</COURSE_NAME>
<COURSE_NBR>MA220</COURSE_NBR>
</Courses_Taken>
<Courses_Taken>
<COURSE_GRD>B</COURSE_GRD>
<COURSE_NAME>Introduction to Psychology</COURSE_NAME>
<COURSE_NBR>PY100</COURSE_NBR>
</Courses_Taken>
</Term>
<Term>
<SEMESTER>SP94</SEMESTER>
<Courses_Taken>
<COURSE_GRD>B</COURSE_GRD>
<COURSE_NAME>Fluid Mechanics</COURSE_NAME>
<COURSE_NBR>EG140</COURSE_NBR>
</Courses_Taken>
<Courses_Taken>
<COURSE_GRD>B</COURSE_GRD>
<COURSE_NAME>Circut Theory</COURSE_NAME>
<COURSE_NBR>EG240</COURSE_NBR>
</Courses_Taken>
<Courses_Taken>
<COURSE_GRD/>
<COURSE_NAME>Calculus - II</COURSE_NAME>
<COURSE_NBR>MA221</COURSE_NBR>
</Courses_Taken>
</Term>
<FNAME>Susan</FNAME>
</STUDENT>
<STUDENT>
<_ID>123456789</_ID>
<LNAME>Martin</LNAME>
<Term>
<SEMESTER>SP94</SEMESTER>
<Courses_Taken>
<COURSE_GRD/>
<COURSE_NAME>Introduction to Psychology</COURSE_NAME>
<COURSE_NBR>PY100</COURSE_NBR>
</Courses_Taken>
<Courses_Taken>
<COURSE_GRD>C</COURSE_GRD>
<COURSE_NAME>Golf - I</COURSE_NAME>
<COURSE_NBR>PE100</COURSE_NBR>
</Courses_Taken>
</Term>
<FNAME>Sally</FNAME>
</STUDENT>
</main>
4-20
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
Schema Attribute
The default schema format is ref type schema. You can use the schema attribute to
define a different schema format.
schema=”inline”|”ref”|”type”
File Attribute
UniVerse uses the File attribute to process both RetrieVe and UniVerse SQL
commands. If you do not define the file attribute exactly as it is used on the command
line, the field element will not be properly processed.
File=”filename”
Field Attribute
The Field attribute defines the field name. The field can be either a data-descriptor,
an I-descriptor, or an ‘association phrase name’. For more information, see “Associ-
ation Elements” on page 24.
Field=”field-name”
Note: The file and field attributes are used to identify the query file and field needed
to change the default directions. Use these attributes in the same element of the XML
mapping file to pinpoint the database file and field.
Map-to Attribute
The Map-to attribute allows you to define a new attribute tag or element tag name for
the field. By default, UniVerse uses the dictionary display field name for the element
or attribute name tag.
Type Attribute
The Type attribute defines how to treat the field in the XML document, either as a
multivalued field or a multi-subvalued field.
type=”MV”|”MS”
Treated-as Attribute
The Treated-as attribute determines if the field should be treated as an element or an
attribute in the generated XML document.
Matchelement Attribute
The Matchelement attribute specifies whether to display empty elements for missing
values or subvalues belonging to the same association, or to ignore the missing
values.
4-22
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
Encode Attribute
The Encode attribute encodes unprintable characters, or characters that have special
meanings in XML, such as { : }, with a macro.
encode=”0x7B 0x7D”
Conv Attribute
The Conv attribute changes the conversion defined in the dictionary record to the
conversion you define.
conv=”new conv code” | conversion = “new conversion code”
Fmt Attribute
The Fmt attribute changes the format defined in the dictionary record to the format
you define.
fmt=”new format code” | format = “new format code”
Association Elements
An association element contains the following four attributes:
4-24
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
Note: The global attributes listed above are not defined because they are set to “1”.
The next example illustrates an XMLSchema using the mapping file in the previous
example.
4-26
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Courses_Taken">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="COURSE_NBR" minOccurs="0"
type="xsd:s
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
>
The next example illustrates an XML document created using the mapping file in the
previous example. Use the following command to display the XML to the screen:
4-28
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
Formatting Considerations
UniVerse does not generally apply the dictionary format pattern to the extracted data.
To specify a format, define it in the mapping file. If you specify a format using the
FMT keyword in a RetrieVe statement, that format will override the format defined
in the mapping file.
Use the encode field in the mapping file to add flexibility to the output. You can
define special characters to encode in hexadecimal form. UniVerse encodes these
special characters to &#x##;. For example, if you want the character ‘{‘ to be
encoded for field FIELD1, specify the following encode value in the mapping file for
FIELD1:
encode=”0x7B”
In this case, UniVerse will convert ‘{‘ found in the data of FIELD1 to {.
You can also use this type of encoding for any nonprintable character. If you need to
define more than one character for a field, add a space between the hexadecimal
definitions. For example, if you want to encode both ‘{‘ and ‘}’, the encode value in
the mapping file should look like the following example:
encode=”0x7B 0x7D”
You can change these mapping defaults in the mapping file, as shown in the following
example:
<U2xml:mapping root=”root_name”
record=”record_name”/>
4-30
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
Mapping Example
The following example illustrates the creation of XML documents. These examples
use the STUDENT file, which contains the following fields:
>LIST DICT STUDENT
Type &
Field......... Field. Field........ Conversion.. Column......... Output
Depth &
Name.......... Number Definition... Code........ Heading........ Format
Assoc..
OURSE_HOURS,C
OURSE_GRD)
TEACHER I TRANS('COURSE Teacher 10L M
CGA
S',COURSE_NBR
,'TEACHER','X
')
COURSE_NAME I TRANS('COURSE Course Name 15T S
CGA
S',COURSE_NBR
,'NAME','X')
COURSE_HOURS I TRANS('COURSE Hours 5R M
CGA
S',COURSE_NBR
,CREDITS,'X')
@ PH LNAME FNAME
MAJOR MINOR
ADVISOR
SEMESTER
COURSE_NBR
Type &
Field......... Field. Field........ Conversion.. Column......... Output
Depth &
Name.......... Number Definition... Code........ Heading........ Format
Assoc..
COURSE_GRD
CGA PH SEMESTER
COURSE_NBR
COURSE_NAME
COURSE_GRD
COURSE_HOURS
TEACHER
@ORIGINAL S @ID M
@SYNONYM S ID M
22 records listed.
Parameter Description
DICT Lists records in the file dictionary of filename. If you do not specify
DICT, records in the data file are listed.
USING [ DICT ] If DICT is not specified, uses the data portion of dictname as the
dictname dictionary of filename. If DICT is specified, the dictionary of
dictname is used as the dictionary of filename.
filename The file whose records you want to list. You can specify filename
anywhere in the sentence. LIST uses the first word in the sentence
that has a file descriptor in the VOC file as the file name.
4-32
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
Parameter Description
TO xmlfile This option redirects the query xml output from the screen to the
&XML& file. This file has a .xml suffix. If you specify
WITHSCHEMA in the query, UniVerse creates an xmlfile.xsd in
the &XML& directory. If you specify WITHDTD, UniVerse creates
an xmlfile.dtd as well.
LIST Parameters (Continued)
Examples
4-34
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
<ROOT>
<STUDENT _ID = "987654321">
<CGA-MV SEMESTER = "FA93" COURSE_NBR = "EG110" COURSE_GRD = "C"
COURSE_NAME =
"Engineering Principles" COURSE_NBR = "MA220" COURSE_NAME =
"Calculus- I" COURSE
_NBR = "PY100" COURSE_GRD = "B" COURSE_NAME = "Introduction to
Psychology"/>
<CGA-MV SEMESTER = "SP94" COURSE_NBR = "EG140" COURSE_GRD = "B"
COURSE_NAME =
"Fluid Mechanics" COURSE_NBR = "EG240" COURSE_GRD = "B"
COURSE_NAME = "Circut Th
eory" COURSE_NBR = "MA221" COURSE_NAME = "Calculus - II"/>
</STUDENT>
<STUDENT _ID = "123456789">
<CGA-MV SEMESTER = "SP94" COURSE_NBR = "PY100" COURSE_NAME =
"Introduction to
Psychology" COURSE_NBR = "PE100" COURSE_GRD = "C" COURSE_NAME =
"Golf - I"/>
</STUDENT>
</ROOT>
>
Using WITHSCHEMA
Use the WITHSCHEMA keyword with the RetrieVe LIST command to create an
XML schema.
Note: If you specify both WITHDTD and WITHSCHEMA in the same RetrieVe
statement, UniVerse does not produce an XML schema.
to define the schema location. If you specify the targetNamespace in the mapping
file, UniVerse generates the following:
schemaLocation=”namespaceURL filename.xsd”
In both of these cases, you can validate the files using the XML schema validator, or
the UniBasic API XDOMValidate() function.
4-36
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
4-38
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
The following map illustrates how to map your student file to this schema. Use the
steps shown below to create the map:
:
<u2
<!-- First set the default settings for the map -->
root="transcript"
record="student"
targetnamespace1="http://www.ibm.com"
schema="type"
xmlns:ibm="http://www.ibm.com"
treated-as="element"
collaosemv="1"
/>
<u2
file="STUDENT"
field="@ID"
map-to="ref"
type="S"
treated-as="attribute"
/>
<u2
file="STUDENT"
field="FNAME"
map-to="firstName"
type="S"
treated-as="attribute"
/>
<u2
file="STUDENT"
field="LNAME"
map-to="lastName"
type="S"
treated-as="attribute"
/>
<!-- Rename the element tags used for the association -->
<u2
file="STUDENT"
field="CGA"
association-mv="semesterReport"
association-ms="results"
/>
4-40
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
treated-as="attribute"
/>
<u2
file="STUDENT"
field="COURSE_NBR"
map-to="courseNumber"
type="MSV"
treated-as="attribute"
/>
<u2
file="STUDENT"
field="COURSE_NAME"
map-to="courseName"
treated-as="attribute"
type="MSV"
/>
<u2
file="STUDENT"
field="COURSE_GRD"
map-to="courseGrade"
type="MSV"
/>
<u2
file="STUDENT"
field="COURSE_HOURS"
map-to="courseHours"
type="MSV"
/>
<u2
file="STUDENT"
field="TEACHER"
map-to="courseInstructor"
type="MSV"
treated-as="attribute"
/>
You can now view the output from the schema using the following command:
:LIST STUDENT FNAME LNAME CGA SAMPLE 1 TOXML XMLMAPPING
transcript.map
<?xml version="1.0"?>
<transcript
xmlns:ibm="http://www.ibm.com"
>
<student ref = "123456789" firstname = "Sally" lastname =
"Martin">
<semesterReport term = "SP94">
<results courseNumber = "PY100" courseInstructor = "Masters">
<courseName>Introduction to Psychology</courseName>
<courseGrade></courseGrade>
<courseHours>3</courseHours>
</results>
<results courseNumber = "PE100" courseInstructor = "Fisher">
<courseName>Golf - I</courseName>
<courseGrade>C</courseGrade>
<courseHours>3</courseHours>
</results>
</semesterReport>
</student>
</transcript>
:
4-42
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
1. Analyze the DTD or XML schema associated with the application to which
you are sending the XML file. Determine which of your dictionary attri-
butes correspond to the DTD or XML schema elements.
2. Create an XML mapping file, if necessary.
3. List the appropriate fields using the UniVerse SQL SELECT command.
To create an XML document from UniVerse SQL, use the UniVerse SQL SELECT
command.
Parameter Description
WHERE clause Specifies the criteria that rows must meet to be selected.
SELECT Parameters
Parameter Description
WHEN clause Specifies the criteria that values in a multivalued column must
meet for an association row to be output.
HAVING clause Specifies the criteria that grouped rows must meet to be selected.
SCHEMAONLY The output will produce a schema for the corresponding query.
XMLDATA Specifies the file containing the extraction rules for the XML
‘extraction_mapping_file’ document. This file is used for receiving an XML file.
TO ‘xmlfile’ This option redirects the query xml output from the screen to the
&XML& file. This file has a .xml suffix. If you specify
WITHSCHEMA in the query, UniVerse creates an xmlfile.xsd
in the &XML& directory. If you specify WITHDTD, UniVerse
creates an xmlfile.dtd as well.
SELECT Parameters (Continued)
You must specify clauses in the SELECT statement in the order shown in the syntax.
For a full discussion of the UniVerse SQL SELECT statement clauses, see Using
UniVerse SQL.
4-44
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
The processing rules for a UniVerse SQL SELECT statement against a single table
are the same as the RetrieVe LIST rules. For a discussion of how UniVerse SQL
processes these statements, see “Creating an XML Document from RetrieVe” on
page 5.
In this mode, UniVerse uses the name of the file containing the first field you
specify in the SELECT statement as the outer-most element in the XML
output. Any singlevalued fields you specify in the SELECT statement that
belong to this file become attributes of this element.
UniVerse processes the SELECT statement in the order you specify. If it
finds a field that belongs to another file, UniVerse creates a sub-element.
The name of this sub-element is the new file name. All singlevalued fields
found in the SELECT statement that belong to this file are created as attri-
butes for the sub-element.
If UniVerse finds a multivalued or multi-subvalued field in the SELECT
statement, it creates a sub-element. The name of this element is the name of
the association of which this field is a member.
When you execute UNNEST against an SQL table, it flattens the multi-
values into single values.
In a sub-query
In a SELECT statement that is part of an INSERT statement.
In a SELECT statement that is part of a UNION definition.
In a SELECT statement that is part of a VIEW definition.
Examples
This section illustrates XML output from the UniVerse SQL SELECT statement. The
examples use sample CUSTOMER, TAPES, and STUDENT files.
4-46
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
The following example lists the dictionary records from the CUSTOMER file that are
used in the examples:
>LIST DICT CUSTOMER
Type &
Field......... Field. Field........ Conversion.. Column......... Output
Depth &
Name.......... Number Definition... Code........ Heading........ Format
Assoc..
TAPE_INFO PH TAPES_RENTED
Type &
DATE_OUT
DATE_DUE
DAYS_BETWEEN
TAPE_COST
TAPE_NAME
UP_NAMES
>LIST DICT TAPES
Type &
Field......... Field. Field........ Conversion.. Column......... Output
Depth &
Name.......... Number Definition... Code........ Heading........ Format
Assoc..
Using WITHSCHEMA
The syntax for the UniVerse SQL SELECT command is:
SELECT command.
SELECT clause FROM clause
[WHERE clause]
[WHEN clause [WHEN clause]...]
[GROUP BY clause]
[HAVING clause]
[ORDER BY clause]
[report_qualifiers]
[processing_qualifiers]
[TOXML [ELEMENTS] [WITHDTD][WITHSCHEMA][SCHEMAONLY]
[XMLMAPPING mapping_file]]
[XMLDATA extraction_mapping_file]
[TO xmlfile];
When the TOXML command is used in SQL, both the mapping file and the TO xml
file need to be quoted
4-48
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
<ROOT>
<CUSTOMER NAME = "Fischer, Carrie">
<TAPES NAME = "Girl Friday">
<TAPES_CATS-MV CAT_NAME = "Comedy"/>
<TAPES_CATS-MV CAT_NAME = "Old Classic"/>
</TAPES>
<CUSTOMER_TAPE_INFO-MV TAPES_RENTED = "V110"/>
</CUSTOMER>
<CUSTOMER NAME = "Smith, Harry">
<TAPES NAME = "Blue Velvet">
<TAPES_CATS-MV CAT_NAME = "Horror"/>
<TAPES_CATS-MV CAT_NAME = "Drama"/>
<TAPES_CATS-MV CAT_NAME = "Avant Garde"/>
</TAPES>
<CUSTOMER_TAPE_INFO-MV TAPES_RENTED = "V2001"/>
<CUSTOMER_TAPE_INFO-MV TAPES_RENTED = "V5004"/>
<CUSTOMER_TAPE_INFO-MV TAPES_RENTED = "V8181"/>
</CUSTOMER>
<CUSTOMER NAME = "Smith, Harry">
<TAPES NAME = "Journey Abroad">
<TAPES_CATS-MV CAT_NAME = "B - Movie"/>
</TAPES>
4-50
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
The following mapping file defines rules for the CUSTOMER and TAPES file.
>ED &XML& CUST_TAPES.map
Top of "CUST_TAPES.map" in "&XML&", 22 lines, 259 characters.
*--: p
001: <U2xml
002: file="TAPES"
003: field = "CAT_NAME"
004: map-to="Cat_name"
005: type="mv"
006: />
007: <u2
008: file="CUSTOMER"
009: field="TAPES_RENTED"
010: map-to="Tapes_rented"
011: TYPE="mv"
012: />
013: <u2
014: file="CUSTOMER"
015: field="DATE_OUT"
016: TYPE="mv"
017: />
018: <u2
019: file="CUSTOMER"
020: field="DATE_DUE"
021: TYPE="mv"
022: />
To use this mapping file in the SELECT statement, specify the XMLMAPPING
keyword, as shown in the following example:
4-52
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
Note: You must surround the name of the mapping file in single quotation marks.
>SELECT CUSTOMER.NAME, TAPES.NAME, CAT_NAME, DATE_OUT, DATE_DUE
FROM CUSTOMER, TAPES WHERE TAPES_RENTED = TAPES.@ID ORDER BY
CUSTOMER.NAME TOXML XMLMAPPING 'CUST_TAPES.MAP';
UniBasic Example
The following example illustrates a UniBasic program that generates an XML
document:
CMD = "LIST STUDENT LNAME COURSE_NBR COURSE_GRD COURSE_NAME
SEMESTER FNAME"
OPTIONS ="XMLMAPPING=student.map"
STATUS = XMLExecute(CMD,OPTIONS,XMLVAR,XSDVAR)
IF STATUS = 0 THEN
STATUS =
XDOMValidate(XMLVAR,XML.FROM.STRING,XSDVAR,XML.FROM.STRING)
IF STATUS <> XML.SUCCESS THEN
STATUS = XMLGetError(code,msg)
PRINT code,msg
PRINT "Validate FAILED."
PRINT XSDVAR
PRINT XMLVAR
END
ELSE
PRINT "Options ":OPTIONS
PRINT 'XML output:'
PRINT XMLVAR
PRINT
END
END
ELSE
STATUS = XMLGetError(code,msg)
PRINT code,msg
PRINT "XMLExecute failed."
END
The next example illustrates the output from the program described in the previous
example:
<?xml version="1.0"?>
<MAIN>
<STUDENT _ID = "123456789" LNAME = "Martin">
<SEMESTER>SP94</SEMESTER>
<COURSE_NBR>PY100</COURSE_NBR>
<COURSE_NBR>PE100</COURSE_NBR>
</STUDENT>
</MAIN>
:
4-54
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
Syntax
XMLExecute(cmd, options, xmlvar, xsdvar)
Description
The XMLExecute function enables you to create an XML document using the
RetrieVe from UniBasic and returns the .xml and .xsd in BASIC variables. By
default, the XMLExecute command generates an XML Schema.
Parameter Description
cmd Holds the text string of the RetrieVe LIST statement or the UniVerse SQL
SELECT statement. [IN]
Parameter Description
4-56
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
Parameter Description
XmlVar The name of the variable to which to write the generated XML document
[OUT]
XsdVar The name of the variable in which to store the XML Schema if one is
generated along with the XML document. [OUT]
XMLExecute Parameters (Continued)
Hidemv Option
This option specifies whether to hide <MV> and </MV> tags for multivalued fields
belonging to an association in the generated XML document and in the associated
DTD or XML Schema. This parameter applies only if the XML document is created
in element mode.
Note: If the document is created in attribute mode, it is not possible to eliminate the
extra level of element tags.
Hidems Option
This option specifies whether to hide <MS> and </MS> tags for multivalued fields
belonging to an association in the generated XML document and in the associated
DTD or XML Schema. This parameter applies only if the XML document is created
in element mode.
Note: If the document is created in attribute mode, it is not possible to eliminate the
extra level of element tags.
The following example shows the results if the HIDEMS option is setset to “1”:
$INCLUDE INCLUDE XML.H
*
* Here we test different Options for HIDEMS, and also ELEMENT mode
4-58
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
The following example shows the output if the HIDEMS attribute is set to “1”:
>RUN BP XML2
XMLMAPPING=student.map HIDEMS=1 ELEMENTS
Options XMLMAPPING=student.map HIDEMS=1 ELEMENTS
XML output
<?xml version="1.0" encoding="UTF-8"?>
<main
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<STUDENT>
<_ID>987654321</_ID>
<LNAME>Miller</LNAME>
<Term>
<SEMESTER>FA93</SEMESTER>
<COURSE_GRD>C</COURSE_GRD>
<COURSE_NAME>Engineering Principles</COURSE_NAME>
<COURSE_NBR>EG110</COURSE_NBR>
<COURSE_GRD/>
<COURSE_NAME>Calculus- I</COURSE_NAME>
<COURSE_NBR>MA220</COURSE_NBR>
<COURSE_GRD>B</COURSE_GRD>
<COURSE_NAME>Introduction to Psychology</COURSE_NAME>
<COURSE_NBR>PY100</COURSE_NBR>
</Term>
<Term>
<SEMESTER>SP94</SEMESTER>
<COURSE_GRD>B</COURSE_GRD>
<COURSE_NAME>Fluid Mechanics</COURSE_NAME>
<COURSE_NBR>EG140</COURSE_NBR>
<COURSE_GRD>B</COURSE_GRD>
<COURSE_NAME>Circut Theory</COURSE_NAME>
<COURSE_NBR>EG240</COURSE_NBR>
<COURSE_GRD/>
<COURSE_NAME>Calculus - II</COURSE_NAME>
<COURSE_NBR>MA221</COURSE_NBR>
</Term>
</STUDENT>
<STUDENT>
<_ID>123456789</_ID>
<LNAME>Martin</LNAME>
<Term>
<SEMESTER>SP94</SEMESTER>
<COURSE_GRD/>
<COURSE_NAME>Introduction to Psychology</COURSE_NAME>
<COURSE_NBR>PY100</COURSE_NBR>
<COURSE_GRD>C</COURSE_GRD>
<COURSE_NAME>Golf - I</COURSE_NAME>
<COURSE_NBR>PE100</COURSE_NBR>
</Term>
</STUDENT>
</main>
Collapsemv Option
This option specifies whether to collapse <MV> and </MV> tags, using only one set
of these tags for multivalued fields belonging to an association in the generated XML
document and in the associated DTD or XMLSchema. This parameter applies only if
the XML document is created in element mode.
Collapsems Option
This attribute specifies whether to collapse <MS> and </MS> tags, using only one
set of these tags for multi-subvalued fields belonging to an association in the
generated XML document and in the associated DTD or XMLSchema. This
parameter applies only if the XML document is created in element mode.
4-60
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
The following example shows the results if the COLLAPSEMS option is set to “1”:
>ED BP XML3
$INCLUDE UNIVERSE.INCLUDE XML.H
CMD = "LIST STUDENT LNAME COURSE_NBR COURSE_GRD COURSE_NAME
SEMESTER FNAME"
*
* Options for COLLAPSEMS
*
OPTIONS ="XMLMAPPING=student.map"
OPTIONS = OPTIONS:' ELEMENTS COLLAPSEMS=1'
PRINT OPTIONS
STATUS = XMLExecute(CMD,OPTIONS,XMLVAR,XSDVAR)
IF STATUS = 0 THEN
STATUS =
XDOMValidate(XMLVAR,XML.FROM.STRING,XSDVAR,XML.FROM.STRING
The following example shows the output if the COLLAPSEMS attribute is set to “1”:
>RUN BP XML3
XMLMAPPING=student.map ELEMENTS COLLAPSEMS=1
XML output
<?xml version="1.0" encoding="UTF-8"?>
<main
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<STUDENT>
<_ID>987654321</_ID>
<LNAME>Miller</LNAME>
<Term>
<SEMESTER>FA93</SEMESTER>
<Courses_Taken>
<COURSE_GRD>C</COURSE_GRD>
<COURSE_NAME>Engineering Principles</COURSE_NAME>
<COURSE_NBR>EG110</COURSE_NBR>
<COURSE_GRD/>
<COURSE_NAME>Calculus- I</COURSE_NAME>
<COURSE_NBR>MA220</COURSE_NBR>
<COURSE_GRD>B</COURSE_GRD>
<COURSE_NAME>Introduction to Psychology</COURSE_NAME>
<COURSE_NBR>PY100</COURSE_NBR>
</Courses_Taken>
</Term>
<Term>
<SEMESTER>SP94</SEMESTER>
<Courses_Taken>
<COURSE_GRD>B</COURSE_GRD>
<COURSE_NAME>Fluid Mechanics</COURSE_NAME>
<COURSE_NBR>EG140</COURSE_NBR>
<COURSE_GRD>B</COURSE_GRD>
<COURSE_NAME>Circut Theory</COURSE_NAME>
<COURSE_NBR>EG240</COURSE_NBR>
<COURSE_GRD/>
<COURSE_NAME>Calculus - II</COURSE_NAME>
<COURSE_NBR>MA221</COURSE_NBR>
</Courses_Taken>
</Term>
<FNAME>Susan</FNAME>
</STUDENT>
<STUDENT>
<_ID>123456789</_ID>
<LNAME>Martin</LNAME>
<Term>
<SEMESTER>SP94</SEMESTER>
<Courses_Taken>
<COURSE_GRD/>
<COURSE_NAME>Introduction to Psychology</COURSE_NAME>
<COURSE_NBR>PY100</COURSE_NBR>
<COURSE_GRD>C</COURSE_GRD>
<COURSE_NAME>Golf - I</COURSE_NAME>
<COURSE_NBR>PE100</COURSE_NBR>
</Courses_Taken>
4-62
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch6.fm
2/21/08
</Term>
<FNAME>Sally</FNAME>
</STUDENT>
</main>
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
You can receive an XML document, then read the document through UniVerse
BASIC, and execute UniVerse BASIC commands against the XML data.
Note: The extraction file can reside anywhere. We recommend that it reside in the
&XML& file, and have a file extension of .ext.
7-3
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch7
2/21/08
...
</U2xml_extraction>
Element Description
start Defines the starting node in the XML file. This specifies where
UniVerse should begin extracting data from the XML file.
dictionary Specifies the UniVerse dictionary of the file name to use when
viewing the XML data.
Extraction File Elements
Element Description
path The XPath definition for the field you are extracting.
Extraction File Elements (Continued)
In XML, the XPath language describes how to navigate an XML document, and
describes a section of the document that needs to be transformed. It also enables you
to point to certain part of the document.
Parameter Description
. Current node.
.. Parent node.
@ Attributes
7-5
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch7
2/21/08
<ROOT>
<STUDENT_record>
<STUDENT>424-32-5656</STUDENT>
<Last_Name>Martin</Last_Name>
<CGA-MV>
<Term>SP94</Term>
<CGA-MS>
<Crs__>PY100</Crs__>
<GD>C</GD>
<Course_Name>Introduction to Psychology</Course_Name>
</CGA-MS>
<CGA-MS>
<Crs__>PE100</Crs__>
<GD>C</GD>
<Course_Name>Golf - I </Course_Name>
</CGA-MS>
</CGA-MV>
</STUDENT_record>
<STUDENT_record>
<STUDENT>414-44-6545</STUDENT>
<Last_Name>Offenbach</Last_Name>
<CGA-MV>
<Term>FA93</Term>
<CGA-MS>
<Crs__>CS104</Crs__>
<GD>D</GD>
<Course_Name>Database Design</Course_Name>
</CGA-MS>
<CGA-MS>
<Crs__>MA101</Crs__>
<GD>C</GD>
<Course_Name>Math Principles </Course_Name>
</CGA-MS>
<CGA-MS>
<Crs__>FA100</Crs__>
<GD>C</GD>
<Course_Name>Visual Thinking </Course_Name>
</CGA-MS>
</CGA-MV>
<CGA-MV>
<Term>SP94</Term>
<CGA-MS>
<Crs__>CS105</Crs__>
<GD>B</GD>
<Course_Name>Database Design</Course_Name>
<CGA-MS>
<Crs__>MA102</Crs__>
<GD>C</GD>
<Course_Name>Introduction of Psychology</Course_Name>
</CGA-MS>
</CGA-MV>
<STUDENT_record>
<STUDENT>221-34-5665</STUDENT>
<Last_Name>Miller</Last_Name>
<CGA-MV>
<Term>FA93</Term>
<CGA-MS>
<Crs__>EG110</Crs__>
<GD>C</GD>
<Course_Name>Engineering Principles</Course_Name>
</CGA-MS>
<CGA-MS>
<Crs__>PY100</Crs__>
<GD>B</GD>
<Course_Name>Introduction to Psychology</Course_Name>
</CGA-MS>
</CGA-MV>
<Term>SP94</Term>
<CGA-MS>
<Crs__>EG140</Crs__>
<GD>B</GD>
<Course_Name>Fluid Mechanics</Course_Name>
</CGA-MS>
<CGA-MS>
<Crs__>MA221</Crs__>
<GD>B</GD>
<Course_Name>Calculus -- II</Course_Name>
</CGA-MS>
</CGA-MV>
</STUDENT_record>
</ROOT>
7-7
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch7
2/21/08
document
version
Comment ROOT
declaration
STUDENT_ STUDENT_
record record
Course Grade Name Course Grade Name Course Grade Name Course Grade Name
In the previous example, each element in the XML document appears in a box. These
boxes are called nodes when using XPath terminology. As shown in the example,
nodes are related to each other. The relationships in this example are:
When you define the XPath in the extraction file, you must indicate how to treat these
different nodes.
The following example illustrates how to specify the STUDENT_record node as the
starting node, and use the STUDENT dictionary file:
<file_extraction start = “ROOT/STUDENT_record ” dictionary =
“STUDENT”/>
If you want to start the extraction at the CGA-MV node, specify the file extraction
node as follows:
<file_extraction start = “ROOT/STUDENT_record/CGA-MV” dictionary =
“STUDENT”/>
7-9
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch7
2/21/08
In the first field extraction, the @ID value in the UniVerse record will be extracted
from the STUDENT node. The text in the STUDENT node will be the value of @ID.
In the next field extraction rule, the LNAME field will be extracted from the text
found in the Last_Name node in the XML document.
UniVerse uses the “/” character to specify levels of the XML document. The “/” tells
the xmlparser to go to the next level when searching for data.
Use a comma (“,”) to tell the xmlparser where to place marks in the data.
The following example illustrates how to define the path for a multivalued field
(SEMESTER) in the XML document:
<field_extraction field “SEMESTER” path = “CGA-MV,Term/text()” />
In this example, the value of the SEMESTER field in the UniVerse data file will be
the text in the Term node. The “/” in the path value specifies multiple levels in the
XML document, as follows:
4. Search for the next CGA-MV node under the same STUDENT, and extract
the text from the Term node belonging to that CGA-MV node, and make it
the next multivalue. The comma tells the xmlparser to get the node
preceding the command for the next sibling.
5. Continue processing all the CGA-MV nodes belonging to the same parent.
Use the comma (“,”) to define where to place marks in the data. You can specify 2
levels of marks, value marks and subvalue marks.
Suppose the XPath definition contains another level of data, as shown in the next
example:
<field_extraction field = “COURSE_NBR” path = “CGA-MV/CGA-MS/
Course_Name/Comment/text()”/>
You must determine where you want the marks to appear in the resulting data. If you
want Comment to represent the multi-subvalue, begin inserting commas after CGA-
MS, since the Comment is three levels below CGA-MS.
<field_extraction field = “COURSE_NBR” path = “CGA-MV/CGA-MS,
Course_Name,Comment/text()” />
7-11
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch7
2/21/08
This is not a valid XPath, since there are more than three levels of XML data. If you
want your data to have subvalue marks between Comment and activities, change the
XPath definition as follows:
<field_extraction field = “COURSE_NBR” path = “CGA-MV/CGA-MS/
Course_Name,Comment,activities/text()” />
The “/” and the “,” characters are synonymous when defining the navigation path,
UniVerse still uses the “/” AND the “,” to define the navigation path of the data, but
only the “,” to determine the location of the marks in the resulting data.
Like multivalued fields, you must start at the XPath with the parent node of the
multivalue.
The next example illustrates how to extract data for a multi-subvalued field:
<field_extraction field = “COURSE_NBR” path = “CGA-MV, CGA-MS,
Crs__/text()” />
The COURSE_NBR field in the UniVerse data file will be extracted as follows:
1. Start at the CGA-MV node in the XML document, under the start node
(ROOT/STUDENT_record).
2. From the first CGA-MV node, go to the next level, the CGA-MS node.
3. From the first CGA-MS node, go to the Crs__ node. Return the text from
the Crs__node, and make that text the first multi-subvalue of
COURSE_NBR.
4. Go back to the CGA-MS node, and search the siblings of the CGA-MS
nodes to see if there are any more CGA-MS nodes of the same name. If any
are found, return the Crs__/text() under these nodes, and make them the next
multi-subvalues of COURSE_NBR.
5. Go back to the CGA-MV node and search for siblings of the CGA-MS node
that have the same CGA-MV node name. If any are found, repeat steps 3 and
4 to get the values for these CGA-MV nodes, and make them multivalues.
The following example illustrates the complete extraction file for the above
examples:
<U2XML_extraction>
<file_extraction start = "/ROOT/STUDENT_record" dictionary =
"D_MYSTUDENT"
<!--field extraction rule in element mode-->
<field_extraction field = "@ID" path = "STUDENT/text()"/>
<field_extraction field = "LNAME" path = "Last_Name/text()"/>
<field_extraction field = "SEMESTER" path = "CGA-MV/Term/text()"/>
<field_extraction field = "COURSE_NBR" path = "CGA-MV, CGA-MS,
Crs__/text"/>
<field_extraction field = "COURSE_GRD" path = "CGA-MV, CGA-MS,
GD/text()"/>
<field_extraction field = "COURSE_NAME" path = "CGA-MV, CGA-MS,
Course_Name/text()"/>
</U2XML_extraction>
1. Familiarize yourself with the elements of the DTD associated with the XML
data you are receiving.
2. Create the extraction file for the XML data.
3. Prepare the XML document using the UniVerse BASIC PrepareXML
function.
4. Open the XML document using the UniVerse BASIC OpenXMLData
function.
5. Read the XML data using the UniVerse BASIC ReadXMLData function.
6. Close the XML document using the UniVerse BASIC CloseXMLData
function.
7. Release the XML document using the UniVerse BASIC ReleaseXML
function.
Status=PrepareXML(xml_file,xml_handle)
7-13
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch7
2/21/08
Parameter Description
xml_file The path to the file where the XML document resides.
xml_handle The return value. The return value is the UniVerse BASIC
variable for xml_handle. Status is one of the following return
values:
XML.SUCCESS Success
XML.ERROR Error
PrepareXML Parameters
Example
The following example illustrates use of the PrepareXML function:
STATUS = PrepareXML(“&XML&/MYSTUDENT.XML”,STUDENT_XML)
IF STATUS=XML.ERROR THEN
STATUS = XMLError(errmsg)
PRINT “error message “:errmsg
STOP “Error when preparing XML document “
END
Status=OpenXMLData(xml_handle,xml_data_extraction_rule,
xml_data_handle)
Parameter Description
xml_data_handle The XML data file handle. The following are the possible
return values:
XML.SUCCESS Success.
XML.ERROR Failed
XML.INVALID.HANDLE Invalid XML handle
OpenXMLData Parameters
Example
The following example illustrates use of the OpenXMLData function:
status = OpenXMLData(“STUDENT_XML”,
“&XML&/MYSTUDENT.ext”,STUDENT_XML_DATA)
If status = XML.ERROR THEN
STOP “Error when opening the XML document. “
END
IF status = XML.INVALID.HANDLE THEN
STOP “Error: Invalid parameter passed.”
END
Status=ReadXMLData(xml_data_handle, rec)
7-15
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch7
2/21/08
Parameter Description
xml_data_handle A variable that holds the XML data handle created by the
OpenXMLData function.
After you read the XML document, you can execute any UniVerse BASIC statement
or function against the data.
Example
The following example illustrates use of the ReadXMLData function:
MOREDATA=1
LOOP WHILE (MOREDATA=1)
status = ReadXMLData(STUDENT_XML,rec)
IF status = XML.ERROR THEN
STOP “Error when preparing the XML document. “
END ELSE IF status = XML.EOF THEN
PRINT “No more data”
MOREDATA = 0
END ELSE
PRINT “rec = “:rec
END
REPEAT
Status=CloseXMLData(xml_data_handle)
where xml_data_handle is the name of the XML data file handle created by the
OpenXMLData() function.
XML.SUCCESS Success
XML.ERROR Failure
XML.INVALID.HANDLE2 Invalid xml_data_handle
Example
The following example illustrates use of the CloseXMLData function:
status = CloseXMLData(STUDENT_XML)
ReleaseXML(XMLhandle)
where XMLhandle is the XML handle created by the PrepareXML() function.
ReleaseXML destroys the internal DOM tree and releases the associated memory.
XMLError(errmsg)
Where errmsg is the error message string, or one of the following return values:
XML.SUCCESS Success
XML.ERROR Failure
7-17
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch7
2/21/08
Example
The following example illustrates a UniVerse BASIC program that prepares, opens,
reads, closes, and releases an XML document:
# INCLUDE UNIVERSE.INCLUDE XML.H
STATUS=PrepareXML("&XML&/MYSTUDENT.XML",STUDENT_XML)
IF STATUS=XML.ERROR THEN
STATUS = XMLError(errmsg)
PRINT "error message ":errmsg
STOP "Error when preparing XML document "
END
STATUS =
OpenXMLData(“STUDENT_XML”,“&XML&/MYSTUDENT.ext”,STUDENT_XML_DATA)
MOREDATA=1
LOOP WHILE (MOREDATA=1)
STATUS=ReadXMLData(STUDENT_XML_DATA,rec)
IF STATUS = XML.ERROR THEN
STOP "Error when preparing the XML document. "
END ELSE IF STATUS = XML.EOF THEN
PRINT "No more data"
MOREDATA = 0
END ELSE
PRINT "rec = ":rec
PRINT "rec = ":rec
END
REPEAT
STATUS = CloseXMLData(STUDENT_XML_DATA)
STATUS = ReleaseXML(STUDENT_XML)
xml_data is the name of the working file you assign to the XML data.
Parameter Description
XMLDATA xml_data Specifies to list the records from the xml_data you prepared.
extraction_file The full path to the location of the extraction file. You must
surround the path in quotation marks.
fields The fields from the dictionary you specified in the extraction file
that you want to display.
LIST Parameters for Listing XML Data
7-19
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch7
2/21/08
When you list an XML document, RetrieVe uses the dictionary you specify in the
extraction file. The following example lists the dictionary records for the
MYSTUDENT dictionary:
>LIST DICT MYSTUDENT
Type &
Field......... Field. Field........ Conversion.. Column......... Output
Depth &
Name.......... Number Definition... Code........ Heading........ Format
Assoc..
5 records listed.
The fields in the dictionary record must correspond to the position of the fields in the
XML extraction file. In the following extraction file, @ID is position 0, LNAME is
position 1, SEMESTER is position 2, COURSE_NBR is position 3, COURSE_GRD
is position 4, and COURSE_NAME is position 5. The dictionary of the
MYSTUDENT file matches these positions.
The following example illustrates listing the fields from the MYSTUDENT XML
document, using the MYSTUDENT.EXT extraction file:
LIST XMLDATA STUDENT_XML "&XML&/MYSTUDENT.EXT" LNAME SEMESTER COURSE_NBR
COURSE
_GRD COURSE_NAME 11:58:01am 19 Oct 2001 PAGE 1
MYSTUDENT. Last Name...... Term Crs # GD. Course
Name..............
7-21
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch7
2/21/08
RELEASE.XML xml_data
xml_data is the name of the working file you assign to the XML data.
[WHERE clause]
[WHEN clause [WHEN clause]...]
[GROUP BY clause]
[HAVING clause]
[ORDER BY clause]
[report_qualifiers]
[processing_qualifiers]
Parameter Description
FROM XMLDATA Specifies the XML document you prepared from which you
xml_data want o list data.
extraction_file Specifies the file containing the extraction rules for the XML
document.
WHERE clause Specifies the criteria that rows must meet to be selected.
WHEN clause Specifies the criteria that values in a multivalued column must
meet for an association row to be output.
HAVING clause Specifies the criteria that grouped rows must meet to be selected.
You must specify clauses in the SELECT statement in the order shown in the syntax.
You can use the SELECT statement with type 1, type 19, and type 25 files only if the
current isolation level is 0 or 1.
For a full discussion of the UniVerse SQL SELECT statement clauses, see the
UniVerse SQL Reference.
7-23
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\Ch7
2/21/08
The following example illustrates displaying the XML document using the UniVerse
SQL SELECT statement:
>SELECT * FROM XMLDATA STUDENT_XML "&XML&/MYSTUDENT.EXT";
MYSTUDENT. Last Name...... Term Crs # Course Name..............
GD.
6 records listed.
>
RELEASE.XML xml_data
7-25
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Appendix
File Description
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
File Description
A-2
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
ENGAGEMENTS.F
Location | Date
List of Concessions CONCESSIONS
List of Rides
LOCATIONS.F RIDES.F List of Operators
List of Acts
List of Equipment
List of Operators
List of Inventor
List of Equipment
List of Livestock
ACTS.F
List of Performers
List of Equipment
List of Livestock EQUIPMENT.F
INVENTO
VENDORS.F LIVESTOCK.F
List of Items
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
12 records listed.
A-4
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
10 records listed.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
A-6
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
ADVANCE
22 records listed.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
13 records listed.
A-8
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
@ PH ID.SUP
ITEM.CODE
TYPE
DESCRIPTION
COST PRICE
12 records listed.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
16 records listed.
A-10
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
GOV.ASSOC PH GOV.AGENCY
GOV.CONTACT
GOV.PHONE
GOV.FAX
GOV.FEE
GOV.CHECK
GOV.RATE
MEDIA.ASSOC PH MEDIA.NAME
MEDIA.CONTACT
MEDIA.PHONE
MEDIA.FAX
@ PH ID.SUP
LOCATION.CODE
DESCRIPTION
PHONE ACRES
SEATS
27 records listed.
A-12
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
RIDE.ID
RIDE.PAY
24 records listed.
A-14
C:\Program Files\Adobe\FrameMaker8\UniVerse 10.2A\retrieve\AppA
2/21/08
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
16 records listed.
A-16
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
Index
Index
paging on 3-21
A specifying multiple 3-18
A keyword 1-27 suppressing fields 3-20
accessing other files 3-6 suppressing subtotals 3-21
activating saved select lists 4-9 BREAK.ON keyword 3-10
active select lists 4-4 text option 3-17
ad hoc calculations in queries 3-3 BREAK.SUP keyword 3-10
AFTER keyword 2-22, 2-23 BY.DSND keyword 2-42
aggregate computations 3-10 BY.EXP keyword 2-42
aggregate functions 1-20 and sorting 2-45
aliases 3-34 BY.EXP.DSND keyword 2-42
for EVAL expressions 3-34 and sorting 2-45
for field names 3-34
AND keyword 2-33
ARE keyword 1-27 C
AS keyword 3-34 C (Centering) option 3-41
associated fields and vertical reports 3- C (Drop empty fields) option 3-46
44 calculations
association names in queries 1-12 in queries 3-3
associations 1-10 performing ad hoc 1-20
attribute-centric mapping mode 6-4 changing field display characteristics
attribute-centric mode on the fly 3-23
creating XML documents from Circus database, see sample database
multiple files 6-36 collating sequence 2-38, 2-39
processing UniVerse SQL column headings
statements 6-33 default for virtual fields 3-33
attribute-centric XML document defining 3-32
creating 6-17 and TRANS function 3-9
averaging 3-10 columns
fields 3-10 adjusting spaces between 3-46
adjusting width of 3-25
COL.HDG keyword 3-32
B commands
BEFORE keyword 2-22, 2-23 RetrieVe 2-4
breaking on values in fields 3-10 using select lists 4-10
breakpoints 1-21, 3-14 comparing
:\Program Files\Adobe\FrameMaker8\UniVerse
10.2A\retrieve\RetrieveIX.doc
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
alphanumeric values 2-22 element-centric XML document 6- suppressing one for specific
field values 20 breakpoint 3-20
to empty strings 2-29 element-centric XML document from DET.SUP keyword 3-11
to homonyms 2-31 multiple files 6-42 and breakpoints 3-18
numeric field values 2-22 mailing labels 3-44 DICT keyword 2-3, 2-14
one field to another 2-31 mapping file 6-9 dictionaries 1-13
string fields mixed-mode XML document 6-22 see also file dictionaries
to a character pattern 2-27 select lists 4-4 display characteristics, using for other
to literal text 2-24 XML document from multiple files fields 3-37
compound selection expressions 2-33 using mapping file 6-51 displaying
shortcuts 2-34 XML document from multiple files data in internal format 2-47
computations, aggregate 3-10 with DTD 6-48 fields 1-17
constructing queries 2-2 to 2-49 XML document from multiple files record IDs 1-17, 2-8
internal view of data 2-47 with multivalues 6-44 specific 1-17
query syntax 2-3 XML document from RetrieVe 6-4 using field names 1-17
selecting records 2-17 XML document with DTD 6-26 using @ phrase 2-13
sorting data 2-38 XML document with UniVerse multivalued fields 1-11
continuation character ( _ ) 1-13 SQL 6-31 record IDs 1-17, 2-8
CONV keyword 3-23, 3-27 &XML& file 6-4, 6-31 DISPLAY.LIKE keyword 3-37
conversion codes 3-27 customizing output 1-20, 3-2 to 3-47 Document Object Model
date conversion examples 3-28 definition 6-3
and dates 3-27 dollars-and-cents conversions 3-30
determining significant digits to be D DTD
displayed 3-31 creating XML document from
D (Date) option 3-41
dollars-and-cents conversions 3-30 multiple files with 6-48
D-descriptors 1-14
masked character conversions 3-29 creating XML document with 6-26
data
masked decimal conversions 3-29 definition 6-2
displaying internal format 2-47
number formatting 3-29
getting an internal view 2-47
numeric field conversions 3-29
internally stored 2-47
time conversion examples 3-29
data descriptors 1-14
E
versus FMT keyword 3-27
databases element-centric mapping mode 6-5
conversion codes 3-27
see also sample database element-centric mode
CONVERSION keyword, see CONV
sample 1-7, A-1 creating XML document from
keyword
date conversions 3-28 multiple files 6-42
conversions
dates processing UniVerse SQL
date 3-28
and CONV keyword 3-27 statements 6-34
numeric 3-29
conversions 3-28 element-centric XML document
time 3-29
inserting in report headings and creating 6-20
copying field display characteristics 3-
footings 3-41 empty strings 2-29
37
defining encoding
COUNT
column headings 3-32 mapping file 6-12
command 1-13
default fields for printing 1-25 ENUM keyword 3-10
option 3-46
deinstalling the sample database 1-9 EQ keyword 2-22
counting values in fields 3-10
demonstration database, see sample EVAL expressions 1-20, 3-3
creating
database for accessing other files 3-6
attribute-centric XML document 6-
detail lines for ad hoc calculations 3-3
17
suppressing 3-11, 3-18 default column heading for 3-33
attribute-centric XML document
and I-descriptors 3-3
from multiple files 6-36
Index 2
10.2A\retrieve\RetrieveIX.doc
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
3 Guide to RetrieVe
10.2A\retrieve\RetrieveIX.doc
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
Index 4
10.2A\retrieve\RetrieveIX.doc
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
conventions in UniVerse 2-17 inserting time and date 3-41 determining if current 2-35
double 3-4 specifying 3-41 LIST.INDEX command 2-35
single 2-17 spreading 3-41 NO.INDEX keyword 2-35
report headings REQUIRE.INDEX keyword 2-35
centering 3-41 SELECT command 1-23, 4-4
R inserting current record ID 3-41 FROM clause 4-12
inserting date 3-41 select lists
R (record ID) option 3-41
inserting page numbers 3-41 active 1-23, 4-4
raw data, reformatting 5-8
inserting time and date 3-41 benefits 4-3
record IDs 1-14, 2-6, 5-5
spreading 3-41 containing field values 4-5
displaying 1-17, 2-8, 2-10
report qualifiers 1-21, 3-39 containing record IDs 4-4
and field 0 2-6
list 3-39 creating 4-4
multipart 2-11
in queries 2-4 creating numbered select lists 4-5
multiple-column primary keys 2-11
VERTICALLY 3-43 creating sublists from 4-13
selecting records by 2-17
reports definition 4-2
sorting records by 2-41
footings 3-41 GET.LIST command 4-9
suppressing display 2-10
headings 3-41 manipulating 4-14
used in redirecting output 5-3
listing vertically 3-43 multivalued fields 4-4
using a select list as source of 4-11
printing 1-25 saved
record selection, see selecting records
REQUIRE.INDEX keyword 2-35 activating 4-9
records
RetrieVe other uses for 4-17
sampling 2-18
definition 1-2, 1-3 saving 4-9
selecting 2-17
and UniVerse SQL 1-28 SAVED.LIST command 4-9
sorting 2-38
verbs 1-13, 2-3, 2-4 SELECT command 4-4
sorting by fields 2-42
RetrieVe commands 2-4 select list 0 4-4
sorting by record IDs 2-41
definition 1-3 as source of record IDs 4-11
specifying in queries 2-3
filenames 1-13 SSELECT command 4-4
redirecting output 5-2 to 5-12
SUM 2-5 using 1-23, 4-2 to 4-17
to a file 5-3
syntax 2-3 using as filenames 4-12
to tape 5-11
ROWS option 3-46 using in commands 4-10
from two or more file sources 5-6
using multivalued fields 4-7
using different record IDs 5-5
using numbered 4-12
using original record IDs 5-3
REFORMAT command 5-3
S where used 4-2
SELECT statement
MTU function 5-11 S (insert page number with Spacing)
creating XML document with 6-31
reformatted files, querying 5-9 option 3-41
processing multiple tables for XML
reformatting raw data 5-8 SAID keyword 2-22
documents 6-33
relational operators 2-22 sample database 1-7, A-1
SELECT statements
used in comparing null values 2-23 deinstalling 1-9
processing rules for XML
used in comparing numeric fields 2- file dictionaries for A-4
documents 6-33
22 installing 1-7
selecting records 2-17
used in comparing string fields 2-22 multivalued fields in 1-10
by character pattern in string field 2-
REMOVE.DEMO.FILES SAMPLE keyword 2-18
27
command 1-7 SAMPLED keyword 2-18
by comparing one field to another 2-
report footings sampling records 2-18
31
centering 3-41 SAVE.LIST command 4-9
by null values in fields 2-29
inserting current record ID 3-41 saving select lists 4-9
by record ID 2-17
inserting date 3-41 SEARCH command 1-23
by values in numeric fields 2-23
inserting page numbers 3-41 secondary indexes 2-34
by values in string fields 2-24
5 Guide to RetrieVe
10.2A\retrieve\RetrieveIX.doc
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
Index 6
10.2A\retrieve\RetrieveIX.doc
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z @
decreasing 3-26
increasing 3-26
WITH keyword 2-20
X
XML
definition 6-2
limitations in UniVerse SQL 6-34
XML document
creating from RetrieVe 6-4
valid 6-3
well-formed 6-3
XML documents
SELECT statement processing
rules 6-33
Symbols
# operator 2-22, 2-23
&XML& file 6-4
creating 6-31
+ (plus sign) 1-13
< operator 2-22, 2-23
<> operator 2-22, 2-23
= operator 2-22
=< operator 2-22, 2-23
=> operator 2-22, 2-23
> operator 2-22, 2-23
>< operator 2-22, 2-23
>= operator 2-22, 2-23
>> prompt 1-23, 4-5
@ phrase 1-14, 1-17, 2-13, 3-2
@ID
field 2-6, 2-11
synonym 2-7
@KEY phrase 2-7, 2-11
@KEY_SEPARATOR
X-descriptor 2-11
@LPTR phrase 1-25, 2-15
@REVISE phrase 2-15
_ (underscore) 1-13
~ (tilde) operator 2-22
7 Guide to RetrieVe