Dtic Ada250450
Dtic Ada250450
Dtic Ada250450
Volume V
Part 8
AD-A250 450
J. Althoff, M. Apicella
Control Data Corporation
Integration Technology Services
2970 Presidential Drive
Fairborn, OH 45324-6209 igL C T I
SMAY 18 19921
September 1990
9? ,
NOTICE
When Government drawings, specifications, or other data are used for any purpose other
than in connection with a definitely related Government procurement operation, the United
States Government thereby incurs no responsibility nor any obligation whatsoever, regardless
whether or not the government may have formulated, furnished, or in any way supplied the
said drawings, specifications, or other data. It should not, therefore, be construed or implied
by any person, persons, or organization that the Government is licensing or conveying any
rights or permission to manufacture, use, or market any patented invention that may in any way
be related thereto.
This technical report has been reviewed and is approved for publication.
This report is releasable to the vational Technical
1Iferuatiom Service (ITIS). it OTIS, it viii be
available to the general public, Including foreign nations
4
DAN
WI L.I S N, Pfect Manager DATE
If your address has changed, if you wish to be removed form our mailing list, or if the
addressee is no longer employed by your organization please notify WRDC/MTI, Wright-
Patterson Air Force Base, OH 45433-6533 to help us maintain a current mailing list.
Copies of this report should not be returned unless return is required by security
considerations, contractual obligations, or notice on a specific document.
Unclasaifed
SECURITY CLASSIFICATION OF THIS PAGE
This manual explains to application programmers how to use the Neutral Data Manipulation Language (NDML).
It also explains the syntax and semantics of each NDML command.
BLOCK 11:
FOREWORD
SUBCONTRACTOR ROLE
iii
PRM 620341200
30 September 1990
TABL O CNTENTS
Acoesion For
NTIS GRA&I
DTIC TAB 0
UnAruounced -
Jut 1f i cot 1.on
By-
Dtstribut.on/
Availability Codeg
V
PRM 620341200
30 September 1990
SECTIQN L
INTRODUCTION
The Neutral Data Manipulation Language, hereafter NDML, was developed by the U. S.
Air Force to provide access to the databases of the Integrated Information Support System (ISS)
Testbed. The NDML allowed its users to work with the heterogeneous, distributed databases on
the USS Testbed as though they constituted a single relational database.
The NDML has been designed to provide as much functionality as possible while
attempting to be logical in application and convenient. The NDML is intended to be used by data
processing personnel and by manufacturing personnel who may have limited knowledge of
database systems.
When stand-alone requests are supported, deviations from the embedded language will be
as few as possible. The differences are due mainly to the requirement that a retrieved table be
presented to host programs a row at a time, while the entire table can be presented in response to a
stand-alone request from an interactive NDML user.
The NDML Precompiler is used to process the application program containing embedded
NDML statements before the host language (COBOL or FORTRAN) compiler is used. The host
language compiler can be used first to debug host language statements, but the NDML precompile
step must precede host-language compilation before executable object code is produced. The use
of the Precompiler is described in the NDML Precompiler Users Manual.
1-1
PRM 620341200
30 September 1990
The important property of the NDML to keep in mind when using this manual is that you
perceive all data to be in the form of tables. Data within the database can be considered to be stored
as tables even if containing only one row of values. Similarly, only tables can be retrieved from
the database, even if the table consists of a single "row" with a single "column" (i.e., only a single
value). This important property of relational databases allows the output of one retrieval command
to be utilized as the input to another operation without worrying about the structure of the data.
Furthermore, "chunks" of data can be retrieved and used without having to specify the structure of
the data for each application and the size of the data chunk.
Tables are usually called "relations" and the terms table and relation will be used
synonymously here. Similarly, rows of the table may be called "records" or "tuples" and columns
may be called "data fields", "data items" or "attributes". An individual number or character string
entry in the table will be called a "value".
Each of the following sections on specific commands begins with the syntax of the
command. The syntax is presented using a method that is described at the beginning of Section 3;
it is similar to the method used in the NDDL manual. The rigorous BNF description of the
language is presented in appendix A. Following the syntax of the command, semantic notes point
out conflicting commands and restrictions that are not supported by the system. This document
should provide sufficient information for an application programmer to begin work. Moreover,
you will find it an appropriate reference in the future when you have become familiar with NDML.
If you are unfamiliar with SQL, you should consult tutorials and references on that
language before using this guide.
References include:
Chamberlin, D.D., et al., "Sequel 2: A Unified Approach to Data Definition, Manipulation, and
Control," IBM Journal of Research and Development. Vol 20, No. 6, Nov. 1976, pp. 560-575.
Date, C.J., A Guide to DB2. Addison-Wesley Publ. Co., 1984.
In addition, many commercial relational database systems offer interface languages similiar
to SQL. The manuals for these languages are useful for becoming acquainted with the general
syntax of SQL.
1-2
PRM 620341200
30 September 1990
SECTION 2
SYSTEM OVERVIEW
The processing system is known as the Common Data Model Processor (CDMP). The
CDMP provides the application programmer with important capabilities to:
The Precompiler also generates a CS/ES Transformer program which will take the final
results of the request, stored in a file as a table with external-schema structure, and convert the data
values into the correct form for presentation. The CS/ES Transformer also performs NDML
function operations on the data.
Finally, the Precompiler generates a Join Query Graph and Result Field Table which are
used by the Distributed Request Supervisor (DRS) during the run-time evaluation of the NDML
request.
2-1
PRM 620341200
30 September 1990
The DRS is responsible for coordination of the run-time activity associated with the
evaluation of an NDML command. It is activated by the application program, which sends it the
names and locations of the query processors to activate along with run-time parameters which are
to be sent to them. The results generated by the query processors are stored as files in the form of
conceptual-schema relations on the host which executed the query process. Using the Join Query
Graph, transmission cost information and data about intermediate results, the DRS determines the
optimal strategy for combining the intermediate results of the NDML command. It issues the
appropriate file transfer request, activates aggregators to perform unions, joins, and NOT IN SET
operations, and activates the appropriate CS/ES Transformer program to transform the final
results. Finally, the DRS notifies the application program that the request is completed, and sends
it the name of the file which contains the results of the request.
The Aggregator is activated by the DRS. An instance of the Aggregator is executed for
each union, join, and NOT IN SET operation performed. It is passed information describing the
operation to be performed and the file names containing the operands of the operation. The DRS
ensures that these files already exist on the host which is executing the particular Aggregator
program. The Aggregator performs the requested operation and stores the results in a file whose
name was specified by the DRS.
2-2
PRM 620341200
30 September 1990
ECION 3
NDML COMMANDS
The following conventions are used in the description of the NDML commands at the
beginning of the following subsections:
3.1 Conventns
3.1.1 Notation
3-1
PRM 620341200
30 September 1990
3.1.3 Ch trCas
Only upper-case letters are recognized by the NDML Precompiler.
3.1.4 WordJ.eaglh
Table labels are limited to 2 characters.
Table and column names are defined by the relational view in use.
3.2.1 Syna
Data are retrieved from the database using the SELECT command. The command has the
following syntax:
SELECT [WITH { EXCLUSIVE) LOCK]
(SHARED
(NO )
[INTO {FILE 'file-name' }]
FILE ':variable-name'
STRUCTURE :variable-name}
[DISTINCT] { [table-label] ALL
:variable-name [(subscript, ... )] = expr-spec ...
FROM table-name [table-label],...
[WHERE predicate-spec
[AND predicate-spec ...1]
[ORDER BY column-spec [direction] ...]
loop construct
where
3-2
PRM 620341200
30 September 1990
direction is ASC
DESC
ASCENDING
DESCENDING
UP
DOWN
expr-spec is / column-spec
column-spec is column-name }
{ table-name.column-name}
{ table-label.column-name}
loop construct is a list of program and/or NDML statements enclosed in braces for the
purpose of transferring retrieved values to program variables, processing host language
statements with the values retrieved, etc.
3.2.2 Comments
3-3
PRM 620341200
30 September 1990
COMM1T/UNDO;
causes a SHARED lock to be requested automatically.
The lock placed by a transaction depends on the implementation of locks in the particular
database systems of the internal schema. The lock placed on the data in the internal schema by the
local database manager usually locks either (1) only the accessed record or (2) the entire accessed
table, depending on the local database. A "LOCK TABLE" command that will ensure that an entire
table, rather than just a record, is locked is not provided in NDML at present. You should assume
onl) that each record accessed is locked.
(c) INTO Phrase and Variable Assignments
The data retrieved by a SELECT command can be either (1) placed into a file or program
structure with the INTO phrase or (2) assigned to program variables using a variable-assignment
construct. Selecting into a program structure is not applicable if you embedded the NDML
statement in a FORTRAN program because structures do not exist in the language.
3-4
PRM 620341200
30 September 1990
The file name can be specified by using the keyword FILE and enclosing the file name in
single or double quotes. If a colon is not the first character following the first quote, then the literal
contents of the quoted character string will be taken to be the name of the file. If the first character
following the first quote is a colon, then the rest of the character string will be taken to be the name
of a program variable, the contents of which is
the name of the file.
There is no default extension or file type for the filename specified in the SELECT
statement. You must explicitly state the extension or file type as part of the file name.
You must supply either the COBOL SELECT and FD layout or the FORTRAN format
statement for the file if the file is to be accessed by the application program.
The file specified on the SELECT statement does not have to have been previously created.
Code will be generated into the application program to create, open, populate, and close the file.
Note, that during execution of the actual modified application program, the file will be closed when
you receive control after the completion of the NDML processing.
The entire result of the SELECT will be placed in the file, one row per record, in the order
normally produced by the SELECT command. A loop construct should not be specified when the
INTO phrase is used to place the results in a file. There will be a one character (COBOL PIC 9 or
FORTRAN CHARACTER *1) null value flag at the beginning of the record for each column
selected; 1 means null, 0 means null. The null field itself will contain the null value specified in the
NDDL DEFINE DATABASE command.
If the user has embedded the NDML statement in a FORTRAN program and is selecting
into a file, the following rules apply. If selecting a character data item, the exact size of the data
item will be allotted in the record. If selecting the statistical function COUNT, 9 spaces will be
allotted. If selecting a floating point data item, or the statistical functions AVG, SUM, or MEAN,
19 spaces will be allotted in the record. These 19 spaces will be in character format. When the
user accesses the final result file, a conversion routine must be called to convert the 19 character
string to a floating point value. If selecting an integer data item, 10 spaces will be allotted in the
record. These 10 spaces will also be in character format. As with the floating point, a conversion
routine must be called to convert the 10 character string to an integer value. If selecting the
statistical functions MIN or MAX, the size allotted will depend on the type of the operand.
Character results will be left justified in the space allotted for the result. Numeric results will be
right justified in the space allotted for the result.
A structure is indicated to receive the retrieved data by the keyword STRUCTURE
followed by a space, a colon and the program name of the structure. The defined data types for the
fields in the structure must agree exactly with those for the corresponding column. For a structure
target, only the first row returned will be placed in the target unless the application program
contains code for a loop construct following the SELECT command. The syntax of the loop
construct is described in subsection 7.2.
3-5
PRM 620341200
30 September 1990
If the user has embedded the NDML statement in a FORTRAN program and is selecting
into program variables, the following rules apply. If selecting a floating point data item, the result
variable must be defined as DOUBLE PRECISION. If the data item is integer, the result variable
must be defined as INTEGER. If the data item is character, the result variable must be defined as
CHARACTER *n, where n is the value of the external schema size. If statistical functions MEAN,
AVG, or SUM are used, the result variables must be defined as DOUBLE PRECISION. If
statistical function COUNT is used, the result variable must be defined as INTEGER. If statistical
function MIN or MAX is used, the result variable must be defined according to the data type of the
data item being selected.
If neither a file, a structure, nor variables are specified to receive the result of the select
command in embedded NDML within an application program, the Precompiler will reject the
NDML SELECT statement. Thus, an assignment of retrieved columns to program variables or an
INTO clause must be specified, but both cannot be specified. Also note that if ALL is specified for
columns, an INTO phrase must be specified.
The following are examples of valid SELECT statements.
SELECT INTO FILE 'DEPT-FILE'
D.DNO D.DNAME D.DLOC D.DSIZE
FROM DEPT D
ORDER BY D.DNO;
SELE'(' INTO STRUCTURE :DEPT-STRUCT
D.DNO D.DNAME D.DLOC D.DSIZE
FROM DEPT D
ORDER BY D.DNO
loop construct
SELECT :DEPTNO = D.DNO :DEPTNAME = D.DNAME
:DEPT'LOC = DDLOC :DEPTSIZE = D.DSIZE
FROM DEPT D
WHERE D.DLOC != 'LAX'
loop construct
(d) SELECT DISTINCT Phrase
The DISTINCT clause on a SELECT statement is used to specify that duplicate rows are to
be removed prior to presentation of the results. Omitting the DISTINCT clause implies that
duplicate rows are not removed unless you specified this clause at NDDL Create View time. If
DISTINCT clause is specified in both the NDML select and the NDDL Create View, the result is
the same as if it had been specified.
3-6
PRM 620341200
30 September 1990
The DISTINCT phrase refers to the entire set of selected columns following it. For
example, SELECT DISTINCT ALL FROM T1 removes only those rows from T1 for which all
column values are identical to those of another row in T1. The DISTINCT processing is applied to
rows in their external-schema formats.
Only columns from a table can be specified; quoted literal data to be duplicated in a column
are not allowed, but can be introduced easily by the application programmer. Arithmetic
expressions involving column data are also not supported; they also can be implemented easily
directly in the application program. For example, the following commands are not supported:
SELECT INTO FILE 'FILE-NAME'
EMP'IS IN DEPARTMENT' EMPDEPT
FROM EMP;
SELECT INTO FILE 'FILE-NAME'
'OVERHEAD IS '0.5 * AMOUNT
FROM CONTRACTS;
The column specification ALL indicates all columns of the single table specified by the rest
of the SELECT statement. The table can be derived from a single table indicated in the FROM
clause, as (optionally) qualified by a WHERE clause. Alternatively, multiple tables can be
specified in the FROM clause if a join operation is specified in a WHERE clause, but columns
from only one table can be retrieved at a time using the ALL specification. For example, the
following query is not supported:
SELECT INTO FILE 'FILE-NAME' ALL 1
FROM TABLE1, TABLE2;
but these following queries are supported:
SELECT INTO FILE 'FILE-NAME' ALL
FROM TABLE1, TABLE2
WHERE TABLE1.CITY = TABLE2.CITY;
SELECT INTO FILE 'FILE-NAME' E.ALL
FROM EMP E, DEPT D
WHERE E.DNO = D.DNO;
3-7
PRM 620341200
30 September 1990
An important requirement that must be observed to use the ALL column specification is that
an INTO phrase must indicate where to place the results of the SELECT because individual
columns cannot be explicitly assigned to program variables in this syntax. The number of data
fields and data types in the target structure or file must correspond to those of the columns, as
discussed in the subsection above on the INTO phrase. In the ALL specification, the layout of the
retrieved columns is in alphabetical order. For example, if there are columns TEAMNO and
TEAM.NAME, their order of retrieval will be TEAMNAME first and then TEAMNO.
Howevcr, the ALL specification is prone to error in embedded NDML because the number and
order of the columns can change if the table is reorganized. Note also that the ALL specification
can refrr to only one table. If more than one table is specified in the FROM clause, the appropriate
table to which the ALL designation applies must be indicated using a table-label.
MIN, MAX and COUNT can be applied to both numeric and string columns. AVG,
MEAN and SUM can be applied only to numeric columns. Functions are applied to columns in
their external-schema formats. Statistic functions ignore nulls in the data. For the empty set,
COUNT returns zero and other functions return an undefined result; the existence of the empty set
for non-COUNT functions results in a condition code set in NDML-STATUS, as discussed
below.
The ORDER BY clause should not be used when functions are specified because
unnecessary processing will be performed (the system may not allow the clause to be specified).
Specification of function DISTINCT before MIN or MAX is ignored. Functions cannot be used in
a WHERE clause because the result of a function is a property of a group of rows rather than of
each row. A SELECT DISTINCT specification should not be used with functions because it
causes unnecessary processing.
3-8
PRM 620341200
30 September 1990
The formats of function results in COBOL are AVG, MEAN and SUM: $9(9)V9(9);
COUNT: S9(9). The formats of function results in FORTRAN are AVG, MEAN and SUM:
F19.9; COUNT: 19. The number of rows returned by the request is contained in the variable
NDML-COUNT (or NDMLCT in FORTRAN) and generated into the application program by the
Precompiler, obviously, it will always have a value of one for function requests. The variable
NDML-STATUS (or NSTATS in FORTRAN) is generated into the applications program by the
Precompiler, obviously, it will always have a value of one for function requests. The variable
NDML-STATUS (for NDMLST in FORTRAN) generated into the application program contains a
code that indicates the success or failure of the request. An all zero code indicates successful
completion; any other code indicates an error. If a function operates on an empty column, a result
may be returned that is not really valid (for example, SUM will return 0.). The NDML-STATUS
(or NDMLST in FORTRAN) flag and associated null indicator should be checked by the
application program before using the result returned by a function.
SELECT INTO FILE 'FILE-NAME'
AVG(P.LEAD-TIME) MIN(P.LEAD-TIME) MAX(P.LEAD-TIME)
FROM PART P WHERE P.SIZE > 100;
SELECT INTO FILE TILE-NAME' COUNT(D.DNAME)
FROM DEPT D, EMP E
WHERE E.DNO = D.DNO;
SELECT INTO 'FILENAME.DAT
MIN(SE.SALARY) MIN(HE.RATE)
FROM SALARIED-EMP SE, HOURLY-EMP HE;
SELECT INTO FILE 'FILE-NAME' COUNT(DISTINCT E.JOB)
FROM EMP E
WHERE E.DNO = 10;
SELECT INTO FILE 'FILE-NAME' COUNT(DISTINCT D.LOC)
FROM DEPT D, NEWDEPT N
WHERE D.NAME = N.DNAME;
Not,. User-defined functions and explicit arithmetic functions (e.g., WEIGHT * 2.2) are not
supported in this release.
(g) FROM Clause
Table labels or table names may or may not be required by the syntax of the particular
request. If two or more tables are specified in the table-list, it is a good idea to be concise and use
table labels or table names to designate columns. When a table is joined with itself, it is necessary
to use table labels to distinguish columns.
3-9
PRM 620341200
30 September 1990
Supported Query:
SELECT INTO FILE 'FILE-NAME' DNO DNAME
FROM EMP
WHERE DTYPE = 'SALES'
AND DLOC = 'SOUTH';
Unsupported Query:
SELECT INTO FILE 'FILE-NAME' DNO DNAME
FROM DEPT
WHERE DNO IN
(SELECT DNO
FROM LOCATION
WHERE DEPTLOC = 'LA');
3-10
PRM 620341200
30 September 1990
The join-predicate comparison allows only the equi-join (=) and NOT IN SET (!=)
operations; the operators <, <=, > and => are not implemented. The join fields compared in a join
or NOT IN SET operation need not have identical data types in the user's (external) view of the
table, except that numeric data must be compared with numeric data and character strings with
character strings.
The equi-join connects a row from each of two tables to form one row in the result table if
the values in the specified columns in the tables are identical. Duplicate rows will be returned if
duplicate rows exist in either table. Rows for which a match is not found are not included in the
result table.
The outer-join operation is a selection procedure that is similar to join, but when rows from
the table specified to the left of the != operator do not match entries in the table to the right, a
"partial" results row will be considered for retrieval. For a more detailed explanation, refer to C.J.
Date, An Introduction to Database Systems. 3rd Edition. Because columns from the table on the
right may have been selected, null values may be introduced. The query may specifically exclude
or include those "partial" rows by use of the IS[NOT] NULL predicate applied to one of the
columns from the right table. For example, with the following request:
SELECT INTO 'FILENAME.TMP' D.DNO D.DNAME E.NAME
FROM DEPT D, EMP E
WHERE D.DNO != E.DNO;
D.DN
2
5
8
3-11
PRM 620341200
30 September 1990
E.DNO
1
4
7
Some columns cannot be specified in a WHERE clause because the column in the
conceptual schema maps to non-normalized database structures in the intrnal-schema databases.
In particular, a conceptual-schema column that maps to a data field in a repeating group in the
internal database will not have a unique value for each row. The Precompiler should recognize this
problem and reject the NDML request. The CDM Administrator (CDMA) should inform the user
of these restrictions before precompilation. The CDMA can determine those by examining
conceptual-internal schema mapping relationships.
3-12
PRM 620341200
30 September 1990
Sorting is done on the columns in their external-schema formats and will be done on the
machine running the application program. The order of the sorted result will depend on the storage
code used by the computer running the applications program. ASCII is to be used whenever
possible. Thus, the result of the same program can differ if it is precompiled and run on different
machines. Note that ASC, ASCENDING and UP are equivalent and that DESC, DESCENDING
and DOWN are equivalent. Null values are treated as the largest representation and will appear last
when the ASCENDING option is chosen and first when the DESCENDING option is chosen.
SELECT INTO 'FILENAME.COB' E.NAME E.DEPT E.PHONE
FROM EMP E
WHERE E.JOBCODE > 50
ORDER BY E.NAME;
SELECT INTO FILE 'FILE-NAME' PART# SIZE
FROM PART
ORDER BY SIZE DESCENDING;
SELECT INTO 'FILENAME.DAT D.DEPT# D.LOC D.CITY
FROM DEPT D
ORDER BY D.CITY ASC D.LOC DESC D.SIZE ASC;
(j) Nulls
Nulls are intentionally introduced in-to a query result by use of the outer join along with
selection of columns from the second table when the data does not match. These can be tested for
with the IS [NOT] NULL predicate. A value to be recognized as NULL for the internal schema
databases will be stored in the CDM. These shall be used when qualifying (use of IS [NOT]
NULL) on an external schema data item that maps to this internal schema value, outside of the
outer join application.
To allow testing of retrieved data values within the loop construct a COBOL condition (or
FORTRAN string) will be added to the user's program that can be tested with an IF statement.
This condition actually will be an array of flags, one occurrence for each selected item, left to right.
The COBOL or FORTRAN element (FLAG-X in COBOL and FLAGAR in FORTRAN) is set to I
if a null value is encountered, zero otherwise. If a null value is found, the value of the user's
variable will be set to the null value specified in the NDDL DEFINE DATABASE command. For
example,
IF FLAG-X (3) =1
3-13
PRM 620341200
30 September 1990
In this example, the user has tested the column A.F for a potential null value. The user
must be careful with nested selects in one routine. The null-column array only refers to the last
row returned (the inner most SELECT on nested selects).
SELECT
(
test here for outer SELECT NULLS
SELECT
I
test here for inner SELECT NULLS
I
test here for inner SELECT NULLS of last inner row retrieved
FROM TABLI A
IF (FLAGAR(3:3) .NE. '0') THEN
ENDIF
EXCLUSIVE OR
(See Appendix A for exact syntax definitions)
WHERE X.A < 5 XDR X.B = 12
3-14
PRM 620341200
30 September 1990
will be translated to
WHERE (X.A <5 OR X.B = 12) AND (X.A > = 5 OR X.B! =12)
and
A.X NOT BETWEEN 'AAA' AND 'KKK'
will be translated to
(A.X < 'AAA' OR A.X > "KKK').
ILQ.EUAL
Note that both <> and != are allowed for inequality tests.
3-15
PRM 620341200
30 September 1990
These definitions are adapted from the current draft of the proposed SQL standard.
In a single column-predicate:
1. Let X denote the result of the first value or column-spec and let y denote the result
of the second value or column-spec. The values x and y must be comparable
values.
2. (x bool-op y) is unknown if x and y must be comparable values.
3-16
PRM 620341200
30 September 1990
12. As implied by the syntax. expressions within parentheses are evaluated first and
when the order of evaluati a is not specified by parenthesis, NOT is applied before
AND, AND is applied before OR, and operators having the same precedence level
are applied from left to right.
(n) Mapping Rules for Select, Query-Combination
The NDML precompiler will be modified to choose a secondary copy of data for retrieval if
the requesting process is on the same host and if the CDMA has permitted it through the use of the
host and if the CDMA has permitted it through the use of the ALLOW RETRIEVAL clause of the
CREATE MAP command. If DIALLOW RETRIEVAL has been specified, which is also the
default, only the primary copy of data will be retrieved. A description of the CREATE MAP
command may be found in the Neutral Data Definition Language (NDDL) User's Guide.
(o) Mapping Rules for Precompiler Generated Referential Integrity Checks
The NDML precompiler will continue to select the primary copy of data.
3-17
PRM 620341200
30 September 1990
FROM
simple-select-combination
I;
{Loop construct
where simple-select-combination is a parenthesized combination of simple selections using the
operators UNION, DIFFERENCE and INTERSECT.
A simple select is
3-18
PRM 620341200
30 September 1990
Case:
4. If the set-operator is UNION, then:
a. Initialize R to an empty table.
b. Insert each row of T and each row "' into R.
5. If the set-operator is INTERSECT, then:
a. Initialize R to an empty table.
b. For each row of T, if a duplicate of that row exists in T", insert that row of T into
R.
6. If the set-operator is DIFFERENCE, then:
a.Initialize R to an empty table.
b.Insert each row of T into R.
c.For each row of R, if a duplicate of that row exists in T, eliminate that row from R.
7. T and T' must have the same number of columns. Corresponding columns in T and
T' must have identical data type descriptions.
3-19
PRM 620341200
30 September 1990
where
3.4.2 Comments
(a) Locking
A DELETE command inside a transaction usually places a "key lock" on deleted rows until
a COMMIT command is encountered. This lock ensures that another process cannot insert a row
with the key of the deleted row until the DELETE action has been finalized by a COMMIT
command. A DELETE command outside of a transaction is usually committed immediately and no
lock is used. Actual lock mechanisms depend on the internal-schema databases.
3-20
PRM 620341200
30 September 1990
The qualifications specified in the WHERE clause of an NDML statement will be "ANDed"
with those specified in the WHERE clause of the CREATE view. These qualifications include the
column to value predicates and may be expressed within nested parentheses. This parenthesized
logic will be enforced by the precompiler. The NDML precompiler will ignore the WHERE ALL
qualification of the NDML statement when CREATE VIEW qualifications exist.
Note: It is permissible to modify rows in the view that are moved thereby out of the view.
Some columns cannot be specified in a WHERE clause because the column in the
conceptual schema maps to non-normalized database structures in the internal-schema databases.
In particular, a conceptual-schema column that maps to a data field in a repeating group in the
internal database will not have a unique value for each row. The Precompiler should recognize this
problem and reject the NDML request. The CDM Administrator should inform the user of these
restrictions before precompilation. The CDMA can determine these by examining the conceptual-
internal schema mapping relationship.
The entity class (in the conceptual schema) may map to just part (or all) of one or more
record types in the actual database (in the internal schema). If just part of a record type is mapped
to, that deleted part is filled will null-values and the remainder is left as is. The null values used are
those specified in the CDM.
The NDML precompiler will generate update transactions for secondary copies if the
CDMA has permitted it through the use of the ALLOW UPDATE clause of the CREATE MAP
command. If DISALLOW UPDATE has been specified, which is the default, only the primary
copy will be updated. The update of these secondary copies are not guaranteed.
Furthermore, the precompiler will not reject multiple subtransactions being generated by an
update action, one subtransaction per copy of data. The precompiler will continue to reject cases,
where for a specified preference one entity class maps to a non-normalized database structure
resulting in multiple subtransactions.
3-21
PRM 620341200
30 September 1990
3-22
PRM 620341200
30 September 1990
where
file-name and variable-name are defined in the host program,
3-23
PRM 620341200
30 September 1990
If you have embedded the NDML statement in a FORTRAN program and you are inserting
from variables, the following rules apply. If a character value is being inserted, the insert variable
must be defined as CHARACTER *n, where n is the exact size of the external data item into which
it is being inserted. If an integer value is being inserted, the insert variable must be defined as an
INTEGER. If a floating point value is being inserted, the insert variable must be defined as
DOUBLE PRECISION.
3-24
PRM 620341200
30 September 1990
The NDML precompiler will generate update transactions for secondary copies if the
CDMA has permitted it through the use of the ALLOW UPDATE clause of the CREATE MAP
command. If DISALLOW UPDATE has been specified, which is the default, only the primary
copy will be updated. The update of these secondary copies are not guaranteed.
Furthermore, the precompiler will not reject multiple subtransactions being generated by the
update action, one subtransaction per copy of data. The precompiler will continue to reject cases,
where for a specified preference, one entity class maps to a non-normalized database structure
resulting in multiple subtransactions.
3-25
PRM 620341200
30 September 1990
01 DEPT-REC.
03 DEPT-NUM PIC 99.
03 DEPT-NAME PIC X(4).
03 DEPT-LOC PIC XX.
03 DEPT-SIZE PIC X(5).
3-26
PRM 620341200
30 September 1990
3.6.1 Synta
The MODIFY command changes values in an external-schema table. The MODIFY
command has the following syntax:
MODIFY table-name [table-label]
[USING table-name [table-label], ... ]
SET column-spec = value ...
WHERE { ALL }
predicate-spec }
where
The columns to be changed and the values to be entered must be explicitly specified in the
SET clause; values cannot be read from a structure or file.
3.6.2 Comments
(a) Integrity Constraints and Mapping Restrictions
Three specific integrity constraints are enforced by the system. First, the MODIFY
command cannot be used to change the values of a column that corresponds to the key class of an
entity class in the conceptual schema. Thus, some requests that have an apparently correct syntax
might be rejected. To modify a key class, it is necessary to first DELETE and then INSERT the
entity. Second, referential integrity is enforced. If a foreign key class is to be modified, there
must exist a parent for the new key. Third, it is not permissible to change just part of a foreign key
class; the entire foreign key must be changed.
3-27
PRM 620341200
30 September 1990
Some columns cannot be modified alone because the column in the conceptual schema
maps to non-normalized database structures in the internal-schema databases. In particular, a
conceptual-schema column that maps to a data field in a repeating group in the internal database
will not have a unique value for each row. The Precompiler should recognize this problem and
reject the NDML request. You can determine these restrictions before precompilation only by
examining conceptual-internal schema mapping relationships.
The NDML precompiler will generate update transactions for secondary copies if the
CDMA has permitted it through the use of the ALLOW UPDATE clause of the CREATE MAP
command. If DISALLOW UPDATE has been specified, which is the default, only the primary
copy will be updated. The update of these secondary copies are not guaranteed.
Furthermore, the precompiler will not reject multiple subtransactions being generated by the
update action, one subtransaction per copy of data. The precompiler will continue to reject cases,
where for a specified preference, one entity class maps to a non-normalized database structure
resulting in multiple subtransactions.
(b) Locking
A MODIFY command within a transaction usually places an EXCLUSIVE lock
automatically (on rows or on tables accessed, depending on the particular internal-schema database
managers) until a COMMIT cjmmand is encountered. A MODIFY command issued outside of a
transaction usually co,- . ., the result immediately. The specific lock used is determined by the
particular internal-scher t database manager.
(c) USING Clause
The USING clause specifies tables that are accessed by the WHERE clause to qualify the
request. These tables need not necessarily include the one that is being modified. To be
meaningful, tables indicated in the USING clause must be related to the table on which the
MODIFY command acts by a join-predicate.
(d) SET Clause
The SET clause specifies the new values that are to be given to values in designated
columns. The new value can be contained in a program variable or be given explicitly. In this
release, new values cannot be calculated by arithmetic expressions in the MODIFY command, nor
can they be contained in a structure or file.
3-28
PRM 620341200
30 September 1990
The qualifications specified in the WHERE clause of an NDML statement will be "ANDed"
with those specified in the WHERE clause of the CREATE view. These qualifications include the
column to value predicates and may be expressed within nested parentheses. This parenthesized
logic will be enforced by the Precompiler. The NDML precompiler will ignore the WHERE ALL
qualification of the NDML statement when CREATE VIEW qualifications exist.
Note: It is permissible to modify rows in the view that are moved thereby out of the view.
Some columns cannot be specified in a WHERE clause because the column in the
conceptual schema maps to non-normalized database structures in the internal-schema databases.
In particular, a conceptual-schema column that maps to a data field in a repeating group in the
internal database will not have a unique value for each row. The Precompiler should recognize this
problem and reject the NDML request. The user can determine these restrictions before
precompilation only by examining conceptual-internal schema mapping relationships.
(f) Examples:
MODIFY OFFER F
SET F.STATUS = 'EXPIRED'
WHERE F.DATE < :CUTDATE;
MODIFY OFFER F
SET F.RESPONSIBLE-DEPT = 'BENEFITS'
WHERE ALL;
MODIFY DEPT D
USING EMPLOYEE EMP
SET D.STATUS = 'INACTIVE'
WHERE D.DNO != EMP.DNO;
3-29
PRM 620341200
30 September 1990
MODIFY DEPT D
SET D.STATUS = 'INACTIVE'
D.LOC = 'INACTIVE'
D.RESPONSIBLE-MNGR = :MNGR-INPUT
WHERE D.DNO = :DEPT-NO-INPUT;
*# BEGIN TRANSACTION;
*# MODIFY OFFER F
*# SET F.RESPONSIBLE-DEPT = 'BENEFITS'
*# WHERE ALL;
IF NDML-STATUS = 'ERROR'
*# ROLLBACK;
ELSE
*# COMMIT;
3-30
PRM 620341200
30 September 1990
3.8.2 Sytax
A loop must immediately follow a SELECT command. If a loop construct follows, do not
end the SELECT command with a ";" because the end of the NDML procedure is indicated by the
closing bracket. The start of the loop is indicated by "{" and the end by ")", both of which are
embedded NDML statements and must be preceded on the line in the application program by
appropriate NDML designation characters. The body of the loop can contain both host-language
statements and embedded NDML commands.
It is permissible to include NDML statements within loop constructs for a SELECT
statement. A transaction defined by a BEGIN TRANSACTION statement must either enclose the
entire SELECT statement and associated loop construct or must be contained within the loop
construct. An example of ti'e latter is given under 3.7.4.
3-31
PRM 620341200
30 September 1990
The following two restrictions on the use of loop constructs are important. Programmers
should not attempt to exit a loop by using a host language GOTO or equivalent statement. The
result of such a jump is undefiaied. Secondly, the NDML commands SELECT, INSERT,
DELETE and MODIFY should not appear within a host-language "IF" statement because the
Precompiler will not be able to gua -antee the integrity of the logic path. The NDML statements
listed under 3.7.4 are provided to control the processing of loops. (The NDML commands
COMMIT, UNDO and ROLLBACK can also be placed within a host-language IF statement).
3.8.4 Evaluation
The following actions are taken by the system to evaluate an embedded NDML SELECT
statement:
1. The system evaluates the query and stores the resulting rows in a result file. If a file
name has been specified by the programmer in an INTO phrase to receive the results,
the result file is given the specified name and the command is finished. Otherwise,
proceed.
2. The code within the loop specified in the SELECT command is executed, once for each
row generated by the query. Values are moved to the program variables or structure
fields specified to receive them. It is necessary that the host language code either move
those values to safe storage or specify new variables (for example, new indices of array
variables) for each execution of the loop if more than one row is returned. The host
language code should also test the number of loops to ensure that the allocated storage
for rturmed information is not exceeded.
3-32
PRM 620341200
30 September 1990
The following example illustrates how program variables that receive information from a
SELECT statement can be manipulated in a loop construct (this and the following examples are
COBOL). Note that the braces should be on a separate line without following code.
The following example shows how a COBOL variable can be used in the WHERE clause
and how the CONTINUE statement can be used. Parts with a null part name are skipped.
Otherwise, counters are incremented depending on the value of the work number.
IF PART-NAME = SPACES
*# CONTINUE .
IF WORK-NO < BREAK-POINT
ADD I TO ODD-LOT-COUNT
ELSE
ADD 1 TO REGULAR-LOT COUNT.
*# }
The following example shows the inclusion of a transaction within a loop construct.
3-33
PRM 620341200
30 September 1990
*EMPNO EMPNO
EMP_NAME EMPLNAME
SPOUSENAME
EMP_MAST EMPL
DATABASE: 2
EMPLNO
SPOUSENAME
MARRIED EMPL
3-34
PRM 620341200
30 September 1990
3. MODIFY EMP_MAST
SET SPOUSENAME = 'NEW MRS X'
WHERE EMPNAME = 'MR X'
4. DELETE FROM EMPMAST
WHERE EMPNO = 100
5. DELETE FROM EMPMAST
WHERE EMPNAME = 'MR X' OR
SPOUSENAME = 'MRS X'
Example 1:
Two subtransactions will be generated to insert into records EMPL of Database: 1 and
MARRIEDEMPL of Database: 2.
There are no restrictions for "insert" Actions. All copies or sources will be updated.
Example 2:
1 subtransaction will be generated to modify record MARRIEDEMPL of Database:2 with
the appropriate qualifications (i.e., where EMPLNO = 100)
Example 3:
This NDML request will be rejected because the record we are attempting to update
(MARRIEDEMPL of Database:2) does not contain the relevant qualification (i.e.,
EMPNAME = 'MR X').
Example 4:
Two subtransactions will be generated to delete records EMPL of Database: 1 and
MARRIEDEMPL of Database:2. The CS to IS Transformer Module (where CS is
conceptual schema and IS is internal schema) will recognize that the qualification criteria is
present in all the records being deleted.
Example 5:
This NDML Delete will fail because both the qualifications are not present in both the
records being deleted.
3-35
PRM 620341200
30 September 1990
3.10 E
Error code values are defined by the IISS error handling philosophy. NTM and
communication system errors are returned to the NDML application. Other codes of interest to the
NDML application are:
3-36
PRM 620341200
30 September 1990
The IISS Precompiler will precompile your application process containing embedded
NDML commands. The Precompiler parses the application program source code and identifies the
NDML commands. It will modify the original application process to include numerous variables
and subroutine calls necessary to implement the NDML commands in the host language. The
Precompiler will generate code (generated query processes) that will be activated at run time to
access the identified internal-schema databases and to perform the required internal-schema to
conceptual-schema transforms. It will also generate code (generated conceptual/external
transformer) that will be activated at run time to perform the required conceptual to external
transforms, statistics functions, ordering of results, and other processes necessary to present the
requested results to the application process.
In order to activate the HSS Precompiler, the procedure file GENAP must be used. This
procedure file enables you to use the IISS Interface Application Generator (GAP), the IISS
Precompiler, the IISS RP-Main Generator, and the required link/load options.
4-1
PRM 620341200
30 September 1990
APPENDIX A
BNF OF THE NDML
A. 1 Conventions
A. 1.1 Notation
Certain conventions are used to describe the form of command
UPPER CASE WORDS denote keywords in the command
LOWER CASE WORDS denote user-defined words
{ }denotes that exactly one of the options within the braces must be selected by the user
or ")" denotes a literal brace character without special meaning
[ ] denotes that the entry within the brackets is optional
A. 1.2 Punctuation
1. A "."is used to separate the table-label (i.e., table alias) from the column-name. The
table-label is used to match a column to a specific table in the list of tables referenced in
the FROM clause.
2. A ":" is placed before the name of a host-language program variable, structure or file
name that will receive returned values.
A-I
PRM 620341200
30 September 1990
A-2
PRM 620341200
30 September 1990
query-expression SELECT
{ INTO external-struct I
scalar-variable-list I
function list )
FROM (query-combination)
[ORDER by scalar-variable-list]
query-combination query-spec I
query-combination set-operator
query-combination
I (query-combination)
set-operator UNIONIINTERSECTIDIFFERENCE
begin-recoverable unit-command BEGIN TRANSACTION;
commit-command COMMIT;
roUback-command UNDO; I ROLLBACK;
A-3
PRM 620341200
30 September 1990
external-struct 'file-name' I
':variable-name' I
STRUCTURE :variable-name
join-op ==!=
predicate-list boolean-terml
predicate-list {OR I XOR)
boolean-term
boolean-term boolean-factor
Iboolean-term AND boolean-factor
quoted-variable 'literal-string'
A-4
PRM 620341200
30 September 1990
A-5