Item Part [ TurboIMAGE/XL Database Management System Reference Manual ] MPE/iX 5.0 Documentation
TurboIMAGE/XL Database Management System Reference Manual
Item Part
The item part defines data items including the data item name, length,
and the user classes that have access to the item. The data set(s) in
which the data item appears is defined in the set part definition.
Syntax
item name, [sub-item count] type designator [sub-item length]
[(read class list/write class list)];
Parameters
item name is the data item name. It must be a valid
TurboIMAGE/XL data name as described earlier in
Table 3-1 . It must be unique within the item
part.
sub-item count is an integer from 1 to 255 that denotes the number
of sub-items within an item. If omitted, the
sub-item-count equals one by default. A data item
whose sub-item count is 1 is a simple item. If the
sub-item count is greater than 1, it is a compound
item.
type designator defines the form in which a sub-item value is
represented in the computer. The type designators
E, I, J, K, P, R, U, X, and Z are described in
Table 3-2 in the section "Data Item Length."
sub-item length is an integer from 1 to 255. It is the number of
halfwords, bytes, or nibbles (depending on the type
designator) in a sub-item. If omitted, it is equal
to 1 by default.
read class list is a group of user class numbers between 0 and 63,
inclusive, separated by commas. User class numbers
are described in chapter 2.
write class list is a group of user class numbers between 0 and 63,
inclusive, separated by commas. User class numbers
are described in chapter 2.
Example
FIRST-NAME, X10 (12,14/11);
Description
There can be no more than 1023 data items in a database. A data item
name can appear in more than one data set definition. For example, a
data item named ACCOUNT appears in both the CUSTOMER and SALES data sets
of the ORDERS database. The complete ORDERS database schema appears at
the end of this chapter.
Data Item Length
Each data item value is allotted a storage location whose length is equal
to the product of the item's sub-item length and its sub-item count. The
unit of measure for the length depends upon the type designator and can
be a halfword, a byte, or a nibble. A halfword is 16 bits, a byte is
eight bits, and a nibble is four bits or a half-byte.
NOTE In this manual, a word is a 32-bit storage unit and a halfword is a
16-bit storage unit. One byte is 8-bits.
[REV BEG]
Table 3-2 describes the type designators and the unit of measure used
for each.
Table 3-2. Type Designators
------------------------------------------------------------------------------------------------
| | | | |
| Unit | Bits | Type | Description |
| | | Designator | |
| | | | |
------------------------------------------------------------------------------------------------
| | | | |
| Halfword | 16-bit | E | A real (IEEE floating point) number. |
| | | | |
| | | I | A signed binary integer in 2's complement form. |
| | | | |
| | | J | Same as I, but QUERY/3000 allows only numbers |
| | | | conforming to specifications for COBOL II |
| | | | COMPUTATIONAL data to be entered. |
| | | | |
| | | K | An absolute binary quantity (no negative |
| | | | values). |
| | | | |
| | | R | A real (HP 3000 floating point) number. |
| | | | |
------------------------------------------------------------------------------------------------
| | | | |
| Nibble | 4-bit | P | A packed decimal number. |
| | | | |
------------------------------------------------------------------------------------------------
| | | | |
| Byte | 8-bit | U | An ASCII character string containing no |
| | | | lowercase alphabetic characters. |
| | | | |
| | | X | An unrestricted ASCII character string. |
| | | | |
| | | Z | A zoned decimal format number. |
| | | | |
------------------------------------------------------------------------------------------------
[REV END]
A data item must be an integral number of halfwords in length regardless
of the type designator and its unit of measure. In other words, data
items of type P, which are measured in nibbles, must have a sub-item
length and sub-item count such that their product is evenly divisible by
4, because 4 nibbles equal 1 halfword. Data items of type U, X, or Z,
which are measured in bytes, must have a sub-item length and sub-item
count such that their product is an even number. If a data item is
defined as U3, it cannot be a simple item and must have an even numbered
sub-item count so that the data item length is an integral number of
halfwords.
A data item cannot exceed 2047 halfwords in length. The entire item,
whether simple or compound, is always handled as a unit by TurboIMAGE/XL.
TurboIMAGE/XL and Program Language Data Types
The type designator, sub-item count, and sub-item length you specify for
a data item defines its length. TurboIMAGE/XL does not perform any
conversions of data or examine the item to check its validity as it is
being added to the database. The only data item values that
TurboIMAGE/XL checks are those specified as part of a lock descriptor in
calls to the DBLOCK procedure. Refer to the discussion on DBLOCK in
chapter 5. There are no rules requiring that a specific type of data
defined by a programming language must be stored in a specific type of
TurboIMAGE/XL data item. However, for consistency, R-type items are
recommended for storing item values in HP 3000 real format and E-type
items are recommended for storing values in IEEE format.
Table 3-3 relates TurboIMAGE/XL type designators and sub-item lengths
to the data types typically used to process them in the available
programming languages.
Note that the UNIT-COST item (P8) in the INVENTORY data set is easier to
process with COBOL II or RPG programs than with the other languages
because packed data is a standard data type in COBOL II and RPG. An
actual database can be designed so that some data sets are processed by
programs coded in one language and others by programs coded in another
language. Another data set can be conveniently processed by programs
written in any of the languages.
Table 3-3. TurboIMAGE/XL Data Types and Programming Languages
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| Data | BBASIC | C | COBOL II | FORTRAN 77 | Pascal | RPG |
| Type | | | | | | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| E2 | Short | float | | Real | Real | |
| | real | | | | | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| E4 | Real | double | | Double precision | Longreal* | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| I | Short | short int | Computational S9 | Integer*2 | -32768..32767 | Binary |
| | integer | | to S9(4) | | [subrange] | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| I2 | Integer | int | Computational | Integer*4 | Integer | Binary |
| | | | S9(5) to S9(9) | | | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| I4 | | | Computational | | Longint | Binary |
| | | | S9(10) to S9(18) | | | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| J | Short | short int | Computational S9 | Integer*2 | -32768..32767 | Binary |
| | integer | | to S9(4) | | [subrange] | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| J2 | Integer | int | Computational | Integer*4 | Integer | Binary |
| | | | S9(5) to S9(9) | | | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| J4 | | | Computational | | Longint | Binary |
| | | | S9(10) to S9(18) | | | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| K1 | | unsigned | | Logical | 0..65535 | |
| | | short | | | [subrange] | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| Kn* | | | | Logical | Integer** | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| Pn | | | Computational-3 | | | Numeric |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
Table 3-3. TurboIMAGE/XL Data Types and Programming Languages (cont.)
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| Data | BBASIC | C | COBOL II | FORTRAN 77 | Pascal | RPG |
| Type | | | | | | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| P4 | | char[2] | Computational-3 | | Packed array | |
| | | | S9(3) | | [1..2] of | |
| | | | | | char** | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| P8 | | char[4] | Computational-3 | | Packed array | |
| | | | S9(7) | | [1..4] of | |
| | | | | | char** | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| R2 | Short | | | Real | Real | |
| sec- | real | | | | | |
| tion | | | | | | |
| | | | | | | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| R4 | Real | | | Double precision | Longreal* | |
| sec- | | | | | | |
| tion | | | | | | |
| | | | | | | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| U | String | char | Display Picture A | Character | Char[subrange] | Character |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| X | String | char | Display Picture X | Character | Char | Character |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| Xn | | char[n] | Display Picture | | Packed array | |
| | | | X(n) | | [1..n] of char | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| Z | | | Display Picture S9 | | | Character |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| | | | | | | |
| Zn | | | Display Picture | | Packed array | |
| | | | S9(n) | | [1..n] of | |
| | | | | | char** | |
| | | | | | | |
----------------------------------------------------------------------------------------------------------
| |
| * The Pascal long real is an extension for double-word floating point. |
| |
| * For data type Kn, n is a length qualifier ranging from 2 to 255, inclusive. Note |
| that, although the Schema Processor, DBSCHEMA, allows you to define a Kn data type, |
| not all languages support it. Be sure to select an appropriate data type based on |
| your programming language and report writer requirements. |
| |
| ** These Pascal declarations provide correct storage allocation. |
| |
| sectionchema Processor, DBSCHEMA, allows you to define an E or R data type ranging in |
| length from 1 to 255, inclusive. However, not all languages support these data |
| types. Be sure to select an appropriate data type based on your programming |
| language and report writer requirements. Compiler options are usually required to |
| choose between HP 3000 floating point and IEEE reals. Be sure your program is |
| compiled correctly and check your data values with QUERY/3000. |
| |
----------------------------------------------------------------------------------------------------------
Data Items of Type P.
The bits used to represent the sign of a packed decimal value can vary
depending on whether the value is entered using QUERY/3000, a COBOL II
program, or an RPG program. Here is a summary of what happens in each
case:
* For values entered using QUERY/3000:
NO sign specified: Sign is 11112
PLUS sign specified: Sign is 11002
MINUS sign specified: Sign is 11012
* For values entered using COBOL II:
PICTURE clause specifies NO sign: Sign is 11112
PICTURE clause specifies PLUS sign: Sign is 11002
PICTURE clause specifies MINUS sign: Sign is 11012
* For values entered using RPG:
NO sign or PLUS specified: Sign is 11002
MINUS sign specified: Sign is 11012
When using TurboIMAGE/XL to locate all packed data items with a
particular value (as described under "DBLOCK" in chapter 5), you must be
aware that TurboIMAGE/XL differentiates between unsigned, positive, and
negative data items with the same absolute value. For example, if you
search for all data items with the value +2, TurboIMAGE/XL will not
retrieve any items with the unsigned value 2.
In general, TurboIMAGE/XL treats any two values with different binary
representations as unequal regardless of their type.
Complex Numbers.
Applications programmed in BBASIC or FORTRAN 77 can define and manipulate
complex numbers by using data type R2 with a sub-item count of 2, storing
the real part in the first sub-item and the imaginary part in the second
sub-item.
Business BASIC Decimal Numbers.
BBASIC decimal numbers should be stored as K2 or K4 data types if
QUERY/3000 is to be used on the decimal numbers. QUERY/3000 processes
these decimals via a run-time parameter.
QUERY/3000 and Data Types.
QUERY/3000 supports only a subset of the available data item types. If
you intend to use QUERY/3000, you should consult the QUERY/V Reference
Manual for specific information about the way QUERY/3000 handles the
various TurboIMAGE/XL data types, including compound data items.
Data Item Identifiers
When using the TurboIMAGE/XL procedures described in the chapter 5, you
can reference a data item by name or number. The data item number is
determined by the item's position in the item part of the schema. The
first item defined is item 1, the second is item 2, and so forth.
It is more flexible to use data item names because a change in the order
of the item definitions or deleting an item definition from the schema
might require changes to all application programs referencing the data
items by number. Thus, to maintain program file independence, it is
recommended that you use data item names if possible.
Table 3-4 shows examples of item parts.
Table 3-4. Examples of an Item Part
--------------------------------------------------------------------------------------------
| | |
| Item Example | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| A,I2; | 32-bit signed integer. |
| | |
| MELVIN,3I(1,20/44); | Compound item. Three single halfword signed integers. Read |
| | classes are 1 and 20; write class is 44. (Write classes can |
| | also read.) |
| | |
| BLEVET,J; | Single halfword signed integer between -9999 and 9999 (COBOL |
| | II). |
| | |
| COSTS,2X10; | Compound item. Two 10-character ASCII strings. |
| | |
| DATE,X6; | Six-character ASCII string. |
| | |
| VALUES,20R2(1/8); | Compound item. 20 two-halfword real (HP 3000 floating |
| | point) numbers. Read class is 1; write class is 8. (Write |
| | classes can also read.) |
| | |
| PURCHASE-MONTH,U8; | Eight-character ASCII string with no lowercase alphabetics. |
| | |
| MASK,K2; | 32-bit absolute binary quantity. |
| | |
| TEMPERATURE,17R4; | Compound item. 17 four-halfword real (HP 3000 floating |
| | point) numbers. |
| | |
| SNOW*#@,Z4; | Four-digit zoned decimal (numeric display) number. |
| | |
| POPULATION,P12; | Eleven decimal digits plus a sign in the low order nibble. |
| | Occupies three halfwords. |
| | |
| ATOMIC-WEIGHT,E4; | 64-bit IEEE real. |
| | |
--------------------------------------------------------------------------------------------
MPE/iX 5.0 Documentation