Universe Retrieveuserguide v1123 PDF
Universe Retrieveuserguide v1123 PDF
Guide to RetrieVe
Version 11.2
November 2013
UNV-112-RETR-1
Notices
Edition
Publication date: November 2013
Book number: UNV-112-RETR-1
Product version: Rocket UniVerse V11.2
Copyright
© Rocket Software, Inc. or its affiliates 1985-2014. All Rights Reserved.
Trademarks
Rocket is a registered trademark of Rocket Software, Inc. For a list of Rocket registered trademarks
go to: www.rocketsoftware.com/about/legal. All other products or services mentioned in this
document may be covered by the trademarks, service marks, or product names of their
respective owners.
Examples
This information might contain examples of data and reports. The examples include the names of
individuals, companies, brands, and products. All of these names are fictitious and any similarity
to the names and addresses used by an actual business enterprise is entirely coincidental.
License agreement
This software and the associated documentation are proprietary and confidential to Rocket
Software, Inc., are furnished under license, and may be used and copied only in accordance with
the terms of such license.
Note: This product may contain encryption technology. Many countries prohibit or restrict the
use, import, or export of encryption technologies, and current use, import, and export
regulations should be followed when exporting this product.
Contact information
Website: www.rocketsoftware.com
Rocket Software, Inc. Headquarters
77 4th Avenue, Suite 100
Waltham, MA 02451-1468
USA
Tel: +1 781 577 4321
Fax: +1 617 630 7100
2
Contacting Global Technical Support
If you have current support and maintenance agreements with Rocket Software, you can access
the Rocket Customer Portal to report and track a problem, to submit an enhancement request or
question, or to find answers in the U2 Knowledgebase. The Rocket Customer Portal is the primary
method of obtaining support.
www.rocketsoftware.com/support
If you do not already have a Rocket Customer Portal account, you can request one by clicking
Need an account? on the Rocket Customer Portal login page.
Email: u2support@rocketsoftware.com
Telephone:
United Kingdom/France +44 (0) 800 773 771 or +44 (0) 20 8867 3691
3
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Table of
Contents
Table of Contents
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\RetrieveTOC.doc (bookTOC.template)
March 25, 2014 11:07 am
Sorting records by record IDs . . . . . . . . . . . . . 2-41
Sorting records by field values . . . . . . . . . . . . 2-42
Sorting data with multivalues . . . . . . . . . . . . . 2-44
Getting an internal view of your data . . . . . . . . . . . . 2-47
Table of Contents 5
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
6 Guide to RetrieVe
Appendix A Appendix A: The sample database
DICT ACTS.F file . . . . . . . . . . . . . . . . . . . A-4
DICT CONCESSIONS.F file . . . . . . . . . . . . . . . A-5
DICT ENGAGEMENTS.F file . . . . . . . . . . . . . . A-6
DICT EQUIPMENT.F file . . . . . . . . . . . . . . . . A-8
DICT INVENTORY.F file . . . . . . . . . . . . . . . . A-9
DICT LIVESTOCK.F file . . . . . . . . . . . . . . . . A-10
DICT LOCATIONS.F file . . . . . . . . . . . . . . . . A-11
DICT PERSONNEL.F file . . . . . . . . . . . . . . . . A-13
DICT RIDES.F file . . . . . . . . . . . . . . . . . . A-15
DICT VENDORS.F file . . . . . . . . . . . . . . . . . A-16
Table of Contents 7
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 Beta
Chapter
Chapter 1: Introduction
1
What is RetrieVe? . . . . . . . . . . . . . . . . . . 1-4
Using RetrieVe . . . . . . . . . . . . . . . . . . . 1-5
The sample database . . . . . . . . . . . . . . . . . 1-8
Installing the sample database . . . . . . . . . . . . 1-8
Deinstalling the sample database . . . . . . . . . . . 1-10
Multivalued fields . . . . . . . . . . . . . . . . . . 1-11
How multivalued fields are displayed . . . . . . . . . 1-12
Making simple queries . . . . . . . . . . . . . . . . 1-14
File dictionaries . . . . . . . . . . . . . . . . . 1-14
Sorting the output . . . . . . . . . . . . . . . . . . 1-17
Displaying specific fields . . . . . . . . . . . . . . . 1-18
Customizing the output . . . . . . . . . . . . . . . . 1-21
Using select lists . . . . . . . . . . . . . . . . . . 1-24
Printing reports. . . . . . . . . . . . . . . . . . . 1-26
Making queries readable . . . . . . . . . . . . . . . 1-28
RetrieVe and SQL . . . . . . . . . . . . . . . . . . 1-29
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1TOC.fm
March 25, 2014 11:07 am Administering UniData on Windows NT or Windows 2000
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
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-4
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
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 (>).
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..............
28 174 Cookies
29 158 Paper Plates
.
.
.
32 records listed.
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......
1-6
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
12 records listed.
These examples (and the remaining examples in this manual) use a database
representing 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, “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
corresponding .T tables.
1-8
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
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.
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-10
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
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-dimen-
sional 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.
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-12
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
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.
1-14
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
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.
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
1-16
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
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.
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, “Chapter 2: Constructing queries,” for further
information.
1-18
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
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-20
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
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.
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
1-22
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
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.
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.
1-24
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
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 flexibility. 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
1-26
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
Output can also be redirected to another file or to tape. These topics are
covered in Chapter 5, “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-28
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch1.fm
3/25/14
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2TOC.fm
March 25, 2014 11:07 am Administering UniData on Windows NT or Windows 2000
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
Query syntax
Before you can use queries effectively, you need to know how they are
structured. RetrieVe queries contain the following elements:
Element Description
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.
2-3
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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).
Verb Description
2-5
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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.
2-7
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
LIST filename
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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 statements 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_SEP-
ARATOR, 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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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
2-15
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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 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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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 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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
The relational operator you use in a selection expression depends on the type
of data you are comparing: numeric or string.
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
2-23
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
10 Franks $110.91
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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.
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
Enter this
To test for a pattern of… character code…
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).
2-29
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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
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.
2-31
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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
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
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.....
2-33
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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
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.
If your query uses a secondary index that has not been updated, the
report you produce may not match the data actually in the file.
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.
2-35
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
18 records listed.
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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.
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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
Justification Differences
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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.
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
2-45
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
171 41 T-shirts
169 42 Cheese Slices
165 33 Elephant Chow
162 23 Sausages
158 29 Paper Plates
.
.
.
45 records listed.
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.
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
.
.
.
2-47
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch2.fm
3/25/14
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
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
2-49
2Administering 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 Beta
Chapter
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3TOC.fm
March 25, 2014 11:07 am Administering UniData on Windows NT or Windows 2000
C:\Users\awaite\Documents\U2Doc\
UniVerse\11.2\Source\retrieve\Ch3.fm
This chapter shows you how to control the way in which the output from a
query is displayed or printed.
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).
3-2
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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.
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
.
.
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 )
8 V C R 201
Security System 29
Wild West Photo Stand 192
9 Subsidiary Reserve Tent 118
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.
3-8
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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.
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
3-10
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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.
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
3-12
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
45 records listed.
========
TOTALS 45
========
AVERAGES 7.5
========
COUNTS 6
6 records summed.
===== ==========
TOTALS 5853 $2,394.82
45 records summed.
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
3-14
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
.
.
.
Z Large Cat Chow $17.59
Z Ticket Stock $57.13
** ----------
Z $74.72
==========
$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
231 $4,345.59
===============
$1,638,334.64
TOT: ==========
$2,394.82
45 records listed.
3-16
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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:"
TOT: ==========
$2,394.82
45 records listed.
Note that, when labelling grand totals and subtotals, the width of your text is
determined 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 Expres-
sions” 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
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.
3-18
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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
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.
3-20
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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-22
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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
3-24
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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..................
3-26
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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.
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
3-28
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
Time conversions
A value of 5 pm in the TIME field of the ENGAGEMENTS.F file is used as the
source value.
Numeric conversions
Numeric conversions can be masked character (MC), masked decimal (MD),
formatting numbers, and so on.
Conversion
Code Explanation Example
Conversion
Code Explanation Example
MD22 Allows two decimal positions, and scales the 5.3465 becomes .05
stored 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-30
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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.
3-32
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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
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
3-34
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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.
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
3-36
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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.
14 8078
16 3495
17 2861
28 9832
29 4873
.
.
.
45 records listed.
3-38
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
3-40
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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
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.
3-42
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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
DEP........... Z
PURCHASE.DATE. 08/21/93
.
.
.
61 records listed.
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.
3-44
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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.
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:
3-46
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch3.fm
3/25/14
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
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch4TOC.fm
March 25, 2014 11:07 am Administering UniData on Windows NT or Windows 2000
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch4.fm
3/25/14
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.
4-3
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch4.fm
3/25/14
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
4-5
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch4.fm
3/25/14
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:
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.
4-7
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch4.fm
3/25/14
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.
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch4.fm
3/25/14
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.
4-11
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch4.fm
3/25/14
Note that Kwik Outlets appears twice because two items were purchased
from them prior to 1990.
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch4.fm
3/25/14
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.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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch4.fm
3/25/14
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.
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
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 Beta
Chapter
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch5TOC.fm
March 25, 2014 11:07 am Administering UniData on Windows NT or Windows 2000
C:\Users\awaite\Documents\U2Doc\
UniVerse\11.2\Source\retrieve\Ch5.fm
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.
5-2
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch5.fm
3/25/14
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 determines 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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch5.fm
3/25/14
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch5.fm
3/25/14
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch5.fm
3/25/14
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 defini-
tions 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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch5.fm
3/25/14
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 Beta
Chapter
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6TOC.fm
March 25, 2014 11:07 am Administering UniData on Windows NT or Windows 2000
C:\Users\awaite\Documents\U2Doc\
UniVerse\11.2\Source\retrieve\Ch6.fm
XML was developed by the World Wide Web Consortium (W3C), who
describe XML as:
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 UniVerse BASIC, UniVerse SQL, or RetrieVe. In order to work
with the XML documents in UniVerse, you will need to know some key
terms:
6-2
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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.
6-4
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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 attri-
butes correspond to the DTD or XML Schema elements. You can also
refer to “Mapping to an external schema” on page 36 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.
6-6
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
Element-centric mode
In the element-centric mode, as in the attribute-centric mode, each record
becomes an XML element. The following rules apply:
6-8
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
</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.
6-10
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
<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>
>
6-12
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
<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.
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”
/>
...
6-14
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
</U2xml-mapping>
The XML mapping file is, in itself, in XML format. There are three types of
significant elements: the root element, the field element, and the association
element.
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
characteristics 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.”
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 associ-
ation phrase, it is an association 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.
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.
6-16
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
Empty attribute
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”
In this case, UniVerse does not qualify the schema element or the XML
document element.
6-18
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
>RUN BP XML4
XMLMAPPING=student.map ELEMENTS
TARGETNAMESPACE=www.rocketsoftware.com
Options XMLMAPPING=student.map ELEMENTS
TARGETNAMESPACE=www.rocketsoftware.com
XML output
<?xml version="1.0" encoding="UTF-8"?>
<main
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="www.rocketsoftware.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>
6-20
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
<xsd:sequence>
<xsd:element name="SEMESTER" type="xsd:string"/>
<xsd:element ref="intf:Courses_Taken" minOccurs="0"
maxOccurs="unbound
ed"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Courses_Taken">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="COURSE_GRD" type="xsd:string"/>
<xsd:element name="COURSE_NAME" type="xsd:string"/>
<xsd:element name="COURSE_NBR" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
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 infor-
mation, see “Association elements” on page 23.
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.
6-22
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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:
6-24
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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.
</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>
>
6-26
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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:
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 {.
6-28
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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”/>
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
6-30
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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
USING [ DICT ] If DICT is not specified, uses the data portion of dictname as
dictname the 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.
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)
6-32
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
Examples
<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>
>
6-34
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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.
In both of these cases, you can validate the files using the XML schema
validator, or the UniVerse BASIC API XDOMValidate() function.
6-36
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
The following map illustrates how to map your student file to this schema.
Use the steps shown below to create the map:
6-38
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
:
<u2
<!-- First set the default settings for the map -->
root="transcript"
record="student"
targetnamespace1="http://www.rocketsoftware.com"
schema="type"
xmlns:rocketsoftware="http://www.rocketsoftware.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"
/>
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"
/>
6-40
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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:rocketsoftware="http://www.rocketsoftware.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>
:
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
6-42
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
Parameter Description
HAVING clause Specifies the criteria that grouped rows must meet to be
selected.
XMLDATA Specifies the file containing the extraction rules for the
‘extraction_mapping_file’ XML 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.
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 attributes for the sub-element.
6-44
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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.
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..
6-46
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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
6-48
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
<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>
6-50
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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: />
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';
6-52
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
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>
:
Syntax
XMLExecute(cmd, options, xmlvar, xsdvar)
Description
The XMLExecute function enables you to create an XML document using the
RetrieVe from UniVerse BASIC and returns the .xml and .xsd in UniVerse
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]
6-54
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
Parameter Description
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.
6-56
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch6.fm
3/25/14
Note: If the document is created in attribute mode, it is not possible to eliminate the
extra level of element tags.
Note: If the document is created in attribute mode, it is not possible to eliminate the
extra level of element tags.
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.
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta
Chapter
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7TOC.fm
March 25, 2014 11:07 am Administering UniData on Windows NT or Windows 2000
C:\Users\awaite\Documents\U2Doc\
UniVerse\11.2\Source\retrieve\Ch7.fm
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7.fm
3/25/14
...
</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.
Extraction File Elements
Element Description
path The XPath definition for the field you are extracting.
Extraction File Elements (Continued)
Parameter Description
. Current node.
.. Parent node.
@ Attributes
7-5
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7.fm
3/25/14
<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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7.fm
3/25/14
document
version
Comment ROOT
declaration
STUDENT_ STUDENT_
record record
Course Grade Name Course Grade Name Course Grade Name Course Grade Name
When you define the XPath in the extraction file, you must indicate how to
treat these different nodes.
7-9
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7.fm
3/25/14
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”/>
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:
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()”/>
7-11
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7.fm
3/25/14
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()” />
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 activ-
ities, 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>
7-13
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7.fm
3/25/14
Status=PrepareXML(xml_file,xml_handle)
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7.fm
3/25/14
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7.fm
3/25/14
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.
7-19
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7.fm
3/25/14
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7.fm
3/25/14
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
xml_data you 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.
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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\Ch7.fm
3/25/14
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 BetaBeta Beta
Appendix
File Description
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\AppA.fm
3/25/14
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\AppA.fm
3/25/14
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
File Description
A-2
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\AppA.fm
3/25/14
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
ENGAGEMENTS.F
Location | Date
List of Concessions CONCESSIONS
List of Rides
LOCATIONS.F RIDES.F List of Operators
List of Acts
List of Equipmen
List of Operators
List of Invento
List of Equipment
List of Livestock
ACTS.F
List of Performers
List of Equipment
List of Livestock EQUIPMENT.F
INVENTOR
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 Beta Beta
12 records listed.
A-4
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\AppA.fm
3/25/14
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
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 Beta Beta
A-6
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\AppA.fm
3/25/14
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
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 Beta Beta
13 records listed.
A-8
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\AppA.fm
3/25/14
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
@ 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 Beta Beta
16 records listed.
A-10
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\AppA.fm
3/25/14
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 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:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\AppA.fm
3/25/14
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 Beta Beta Beta Beta
RIDE.ID
RIDE.PAY
24 records listed.
A-14
C:\Users\awaite\Documents\U2Doc\UniVerse\11.2\Source\retrieve\AppA.fm
3/25/14
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 Beta Beta Beta Beta
16 records listed.
A-16