HP 3000 Manuals

Database Disc Files (TurboIMAGE) [ HP RPG/XL Programmer's Guide ] MPE/iX 5.0 Documentation


HP RPG/XL Programmer's Guide

Database Disc Files (TurboIMAGE) 

The following list summarizes the advantages and disadvantages of using
TurboIMAGE databases.  For detailed information on TurboIMAGE, see the
TurboIMAGE/XL Database Management System manual.

Advantages: 

 *  Query (QUERY) facilities

 *  Security to the data field level

 *  Data integrity in a multiuser environment

 *  Automatic maintenance of data interrelationships

 *  Data-dictionary approach to files

 *  Efficient memory usage in a multiuser environment

 *  Flexible locking strategies

 *  Rapid access by key

Disadvantages: 

 *  No chronological access

 *  No partial, generic or sequential-within-limits key access

 *  Inefficient disc usage when actual file size varies considerably (the
    maximum file size must be allocated regardless of the space that is
    actually used)

 *  Inability to update a key field

 *  No undo for data deletes

 *  No duplicate keys in master data sets

 *  Databases are not processed by most system software (for example,
    EDITOR, FCOPY and SORT)

 *  No one-step method for using standalone sorts

The remainder of this chapter tells you how to create and use TurboIMAGE
databases within RPG programs.  To simplify the examples, a single
database (MARKET) is used throughout.  MARKET keeps customer account
information and is used online by a marketing department.  MARKET has
four data sets.  D-ACCOUNTS is a detail data set having NAME-LAST and
ACCOUNT-NO as keys.  The automatic masters, A-LAST-NAME and A-ACCOUNT-NO
keep track of these keys.  M-SOURCE is a manual master data set that is
used to validate source codes and to keep track of customer responses by
source code.  It has only a few fields, and is updated infrequently.
Figure 3-22 shows the structure of the MARKET database.

[]
Figure 3-22. The MARKET Database Creating a TurboIMAGE Database There are four steps to creating and loading data into a TurboIMAGE database. First, you create a schema file that defines the database, its data sets and data items. Next, you build the database by creating a root file and then running DBUTIL. Finally, you write a program to load data into the database. The next sections explain each of these steps in detail. Defining a TurboIMAGE Database Schema. The first step in creating a TurboIMAGE database is to create the schema for it. It is assumed that you are familiar with TurboIMAGE, and that you know how to code the various entries to define the schema. You can use EDITOR or any standard text processor to create the schema file. For information on TurboIMAGE, see the TurboIMAGE/XL Database Management System manual. Figure 3-23 shows the schema that defines the MARKET database shown in Figure 3-20. The data sets in MARKET are shaded for easy reference.
[]
Figure 3-23. The Schema For the Market Database
[]
Figure 3-23. The Schema For the Market Database (Continued)
[]
Figure 3-23. The Schema For the Market Database (Continued)
[]
Figure 3-23. The Schema For the Market Database (Continued) Creating a TurboIMAGE Root File. Once you define a TurboIMAGE schema, you then create a TurboIMAGE root file. For example, to create the root file for our sample MARKET database, enter these commands at the operating system colon prompt: :FILE DBTEXT=MARKET.PUB :FILE DBSLIST=$STDLIST :RUN DBSCHEMA.PUB.SYS;PARM=3 If there are any schema or execution errors, they are displayed next. When the root file is successfully created, you see the message END OF PROGRAM.
NOTE Instead of equating DBSLIST to $STDLIST in the file equation, you can assign it to other devices. For example, $NULL or DEV=LP.
Running DBUTIL. After creating a TurboIMAGE root file, you create an empty database. For example, to create an empty database for our sample MARKET database, enter these commands: :RUN DBUTIL.PUB.SYS >>CREATE MARKET >>EXIT When an empty database is created successfully, you see the message data base MARKET has been created.
CAUTION Enter the CREATE command carefully. DBUTIL commands perform many functions, one of which purges databases.
Loading Data into a TurboIMAGE Database. You can use an RPG program to load data into a TurboIMAGE database. You do this by entering TurboIMAGE-specific fields in the File Description and File Description Continuation Specifications. The program in Figure 3-24 shows how to load the D-ACCOUNTS data set (see our sample MARKET database in Figure 3-23) with data from an MPE file, ACCTSIN. Records in ACCTSIN are sorted by account number (ACTNO).
[]
Figure 3-24. Loading a TurboIMAGE Database
[]
Figure 3-24. Loading a TurboIMAGE Database (Continued) Comments 1 This line defines the accounts file, ACCTSIN. 2 This line defines the TurboIMAGE data set file, DACCOUNT. Column 31 is A to indicate that DACCOUNT has an alphanumeric key. Column 32 contains M to indicate that DACCOUNT is a TurboIMAGE file. 3 This line specifies that DACCOUNT is part of the MARKET database. Column 53 is K to indicate that this line is a Continuation line. Columns 54-65 identify MARKET as the TurboIMAGE database that is used. Column 66 is 3 to specify Open Mode - Exclusive Access. Column 67 is blank to specify Input/Output Mode - Write, Output File. 4 This line establishes write access to the database. Column 53 is K to indicate that this is a Continuation line. Columns 54-65 contain LEVEL WRITER to specify the write-access password for the database. 5 This line identifies the key field for the data set. Column 53 is K to indicate that this is a Continuation line. Columns 54-65 contain DSNAMED-ACCOUNTS to identify the data set, D-ACCOUNTS to be accessed (this line is not needed when line 2 contains the actual data set name). 6 This line begins the description of the ACCTSIN input record. 7 This line begins the description of the DACCOUNT output record. Reading a TurboIMAGE Data Set You can access data in a TurboIMAGE data set three different ways and each of these is discussed in the sections which follow: * Sequentially (not in key order) * Sequentially by full key values * Randomly by key value Reading a TurboIMAGE Data Set Sequentially. Since TurboIMAGE does not maintain the sequential order of keys in its data sets, you cannot read the entire data set from beginning to end by a specific key. However, you can retrieve all of the records in their stored unsorted sequence. This may be useful, for example, for extracting data set records for a sort. Figure 3-25 shows how to retrieve all of the records in the TurboIMAGE data set, D-ACCOUNTS (see the schema for this data set in Figure 3-23), and how to display the first four fields in them.
[]
Figure 3-25. Reading a TurboIMAGE Data Set Sequentially Comments 1 This line defines the TurboIMAGE data set file, DACCOUNT. 2 This line defines the database containing D-ACCOUNTS and the security provisions for accessing the database. Column 53 is K to indicate that this is a Continuation line. Columns 54-65 identify MARKET as the TurboIMAGE database that is used. Column 66 is 6 to indicate Open Mode 6 - Shared Read Access. Column 67 is 2 to specify Input/Output Mode 2 - Serial Read. 3 This line establishes the password for the database. Columns 54-65 contain LEVEL READER to specify the password, READER. This password establishes a user class identification that permits read access to the database. 4 This line defines the data set to be used. Columns 54-65 contain DSNAMED-ACCOUNTS to identify the data set, D-ACCOUNTS. 5 This line begins the input record description of the DACCOUNT file. 6 This line begins the output record description of the DISPLAY file. Reading a TurboIMAGE Data Set Sequentially By Key. This section explains how to read all records in a detail data set having a specific key value. This method is useful when a data set contains records with duplicate keys. Unlike KSAM files, you cannot read a TurboIMAGE data set sequentially by a range of key values (reading sequentially within key limits). The program in Figure 3-26 finds and displays all records in the data set, D-ACCOUNTS, having the same last name. The last name field (NAME-LAST) is defined as a key in the data set (see the schema for the data set in Figure 3-23). A user enters a last name from a terminal. When the last name does not exist, one of two warning messages (NO SUCH NAME or END OF CHAIN) is displayed.
[]
Figure 3-26. Reading a TurboIMAGE Data Set Sequentially by Key
[]
Figure 3-26. Reading a TurboIMAGE Data Set Sequentially by Key (Continued) Comments 1 This line defines the TurboIMAGE data set file, DACCOUNT. Columns 28-38 indicate that DACCOUNT is a TurboIMAGE file to be processed randomly by the NAME-LAST key field (positions 19-34). 2 This line specifies that DACCOUNT is part of the MARKET database. Columns 54-65 identify MARKET as the TurboIMAGE database that is used. Column 66 is 6 to indicate Open Mode 6 - Shared Read Access. Column 67 is C to indicate Input/Output Mode C - Chained Sequential Read. In this mode, records are read sequentially along the data set chain. 3 This line defines the password for the database. Columns 54-65 contain LEVEL READER to specify the password, READER. This password establishes a user class identification that permits read access to the database. 4 This line identifies the key field for the data set. Columns 54-65 contain ITEM NAME-LAST to identify the key field, NAME-LAST. 5 This line identifies the data set to be used. Columns 54-65 contain DSNAMED-ACCOUNTS to identify the data set, D-ACCOUNTS. 6 This line begins the input record description for the DACCOUNT file. 7 This line establishes the head of the chain in the D-ACCOUNTS data set. Columns 18-27 contain BLK16 to reset the file pointer to the head of the chain. Columns 28-32 contain CHAIN to specify a "dummy" chained read operation. This operation simply establishes a new head of chain. Columns 33-42 specify the name of the TurboIMAGE data set file, DACCOUNT. 8 This line is the beginning of the loop that reads records in the D-ACCOUNTS data set. 9 This line reads records randomly from the D-ACCOUNTS data set. Columns 18-27 contain INAME to specify the key field. Columns 28-32 contain CHAIN to specify a chained read operation. Columns 33-42 specify the name of the TurboIMAGE data set file, DACCOUNT. Columns 54-55 contain 60 to turn on indicator 60 when a record is not found for the key value in INAME. Columns 56-57 contain 61 to turn on indicator 61 when there are no more records in the data set chain. 10 This line starts the description of the output record to be displayed on the terminal. Reading a TurboIMAGE Data Set Randomly. This section explains how to retrieve master data set records using random key values. The following example takes an account number (ACTNO) entered by a user and verifies it against a list of valid account numbers in the A-ACCOUNT-NO data set. (The schema for this data set is shown in the section "Defining a TurboIMAGE Database Schema.") When an account does not exist, a message (NO HIT ON CHAIN) is displayed.
[]
Figure 3-27. Reading a TurboIMAGE Data Set Randomly Comments 1 This line defines, AACCOUNT, which is a TurboIMAGE automatic master data set. Columns 28-38 indicate that AACCOUNT is a TurboIMAGE file to be processed randomly by the ACCOUNT-NO key field (positions 1-6). 2 This line specifies that AACCOUNT is part of the MARKET database. Columns 54-65 identify MARKET as the TurboIMAGE database that is used. Column 66 is 6 to indicate Open Mode 6 - Shared Read Access. Column 67 is 7 to specify Input/Output Mode 7 - Calculated Read. This mode applies to master data sets only. 3 This line defines the password for the database. Columns 54-65 contain LEVEL READER to specify the password READER. This password establishes a user class identification that permits read access to the database. 4 This line identifies the key field for the data set. Columns 54-65 contain ITEM ACCOUNT-NO to specify that the key for the data set is ACCOUNT-NO. 5 This line names the data set to be accessed. Columns 54-65 contain DSNAMEA-ACCOUNT-NO to specify that the data set is A-ACCOUNT-NO. 6 This line begins the input record description of the A-ACCOUNT-NO data set. 7 This line reads the data set, A-ACCOUNT-NO randomly. Columns 18-27 contain the name of the key field, ACTNO. Columns 28-32 contain CHAIN to specify a chained read operation. Columns 33-42 specify the name of the TurboIMAGE data set file, AACCOUNT. Columns 54-55 contain 60 to turn on indicator 60 when no record is found having the key value contained in ACTNO. Columns 56-57 contains the default H0 indicator to avoid a compiler warning for the CHAIN operation. The end-of-chain indicator has no meaning for master data sets, since they cannot have duplicate keys. 8 This line starts the description of the output record for OUTPUT. The record contains messages that indicate whether or not the account exists in the master data set. Updating a TurboIMAGE Data Set This section explains how to modify records that already exist in a TurboIMAGE data set. For information on adding and deleting records, see the next two sections. To learn about database security provisions that can be incorporated into your RPG programs, see the section titled "Providing Security for TurboIMAGE Databases and Data Sets." Figure 3-28 shows how to access records in the TurboIMAGE data set D-ACCOUNTS (see the schema for this data set in Figure 3-23) by its key, and change the TYPEC field in those records.
[]
Figure 3-28. Randomly Updating Records in a TurboIMAGE Data Set Comments 1 This line defines the file, INPUT. 2 This line defines the TurboIMAGE data set file, DACCOUNT. Column 15 is U to indicate that DACCOUNT is updated. Column 16 is C for chained (random) access. Column 32 is M to specify that DACCOUNT is a TurboIMAGE file. 3 This line specifies that DACCOUNT is part of the MARKET database. Columns 54-65 identify MARKET as the TurboIMAGE database that is used. Column 66 is 2 to indicate Open Mode 2 - Update-Shared Access. Column 67 is 5 to specify Input/Output Mode 5 - Chained Read. 4 This line defines the password for the database. Columns 54-65 contain LEVEL WRITER to specify the password, WRITER. This password establishes a user class identification that permits write access to the database. 5 This line identifies the key field for the data set. Columns 54-65 contain ITEM ACCOUNT-NO to specify that the key for the data set is ACCOUNT-NO. 6 This line names the data set to be accessed. Columns 54-65 contain DSNAMED-ACCOUNTS to specify that the data set is D-ACCOUNTS. 7 This line begins the input record description of the INPUT file. 8 This line begins the input record description of the DACCOUNT file. 9 This line reads the data set, D-ACCOUNTS, randomly. Columns 18-27 contain ACTNO to specify the key field for reading the data set. Columns 28-32 contain CHAIN to specify a chained read operation. Columns 33-42 specify the name of the TurboIMAGE data set file, DACCOUNT. Columns 54-55 contain 60 to turn on indicator 60 when a record is not found for the account number in D-ACCOUNTS. Even though 60 is not used in the program, an indicator must be entered in this field to prevent the halt indicator (H0) from being turned on. 10 This line begins the output record description for the DACCOUNT file. Adding Records to a TurboIMAGE Data Set This section explains how to add records to a TurboIMAGE data set. Records are added randomly and do not have to be ordered by key value. To learn about database security provisions that can be incorporated into your RPG programs, see the section titled "Providing Security for TurboIMAGE Databases and Data Sets." Figure 3-29 shows how to add records to our sample data set, D-ACCOUNTS. (See the schema for the MARKET database in the section titled "Defining a TurboIMAGE Database Schema.") Records that are added come from the file, IDACCT, which has the same format as the D-ACCOUNTS data set. The ACTNO field in IDACCT is used as the key when reading D-ACCOUNTS, but the input records are not in sequence by this key. Before a record is added to D-ACCOUNTS, a check is made to ensure that the ACTNO record does not already exist.
[]
Figure 3-29. Randomly Adding Records to a TurboIMAGE Data Set Comments 1 This line defines the IDACCT file. 2 This line defines the TurboIMAGE data set file, DACCOUNT. Column 15 is U to indicate that DACCOUNT is updated. Column 16 is C for chained (random) access. Column 66 is A to indicate that records are added to DACCOUNT. 3 This line specifies that DACCOUNT is part of the MARKET database. Columns 54-65 identify MARKET as the TurboIMAGE database that is used. Column 66 is 9 to indicate Open Mode 9 - Data Set Locking per Record. Column 67 is 5 to specify Input/Output Mode 5 - Chained Read. 4 This line defines the password for the database. Columns 54-65 contain LEVEL WRITER to specify the password, WRITER. This password establishes a user class identification that permits write access to the database. 5 This line identifies the key field for the data set. Columns 54-65 contain ITEM ACCOUNT-NO to specify that the key for the data set is ACCOUNT-NO. 6 This line names the data set to be accessed. Columns 54-65 contain DSNAMED-ACCOUNTS to specify that the data set is D-ACCOUNTS. 7 This line begins the input record description of the IDACCT file. 8 This line begins the input record description of the DACCOUNT file. (Since records are being added only, you do not need to define input fields.) 9 This line reads the data set, D-ACCOUNTS, randomly. Columns 18-27 contain ACTNO to specify the key field for reading the data set. Columns 28-32 contain CHAIN to specify a chained read operation. Columns 33-42 specify the name of the TurboIMAGE data set file, DACCOUNT. Columns 54-55 contain 80 to turn on indicator 80 when a record is not found for the account number in D-ACCOUNTS. 10 This line specifies that exception output is performed when indicator 80 is turned on (indicator 80 is turned on when a record is not found for an account number). 11 This line specifies the output operation for adding records to the D-ACCOUNTS data set. Column 15 is E to identify this record as an exception record. Columns 16-18 are ADD to add records to the TurboIMAGE data set. Columns 32-37 are ADDREC to name the EXCPT Name for the record to be added. Deleting Records from a TurboIMAGE Data Set This section explains how to delete records from a TurboIMAGE detail data set. The data set must not contain duplicate keys. Records are deleted by matching their key field values to those specified in the program. To learn about database security provisions that can be incorporated into your RPG programs, see the section titled "Providing Security for TurboIMAGE Databases and Data Sets." Figure 3-30 shows how to delete records from our sample data set D-ACCOUNTS. (See the schema for the MARKET database in the section titled "Defining a TurboIMAGE Database Schema.") The input file, INPUT, contains the keys for the records to delete, though records in INPUT are not sequenced by this key. Each record to be deleted in D-ACCOUNTS is read first to verify that it exists. (If you need to delete records in a data set containing duplicate keys, enter C (Chained Sequential Read) in the Input/Output Mode for the file. Then CHAIN and delete the records until the indicator in columns 56-57 of the CHAIN operation line turns on.)
[]
Figure 3-30. Deleting Records from a TurboIMAGE Data Set Comments 1 This line defines the file, INPUT. 2 This line defines the TurboIMAGE data set file, DACCOUNT. Column 15 is U to indicate that DACCOUNT is updated. Column 16 is C for CHAINed (random) access. 3 This line specifies that DACCOUNT is part of the MARKET database. Columns 54-65 identify MARKET as the TurboIMAGE database that is used. Column 66 is S to indicate Open Mode S - Data Set Locking for Duration. Column 67 is 5 to specify Input/Output Mode 5 - Chained Read. 4 This line defines the password to the database. Columns 54-65 contain LEVEL WRITER to specify the password, WRITER. This password establishes a user class identification that permits write access to the database. 5 This line identifies the key field for the data set. Columns 54-65 contain ITEM ACCOUNT-NO to specify that the key for the data set is ACCOUNT-NO. 6 This line names the data set to be accessed. Columns 54-65 contain DSNAMED-ACCOUNTS to specify that the data set is D-ACCOUNTS. 7 This line begins the input record description of the INPUT file. 8 This line begins the input record description of the DACCOUNT file. 9 This line reads the D-ACCOUNTS data set randomly. Columns 18-27 contain ACTNO to specify the key field. Columns 28-32 contain CHAIN to specify a chained read operation. Columns 54-55 contain 80 to turn on indicator 80 when a record is not found for the account number in D-ACCOUNTS. Columns 56-57 contain the H0 indicator to avoid a compiler warning for the CHAIN operation. The end-of-chain indicator has no meaning since records are accessed randomly. 10 This line performs exception output when the appropriate record is found in D-ACCOUNTS (indicator 80 in not on). 11 This line defines the exception output operation for deleting records. Column 15 is E to identify this record as an exception record. Columns 16-18 are DEL to specify that records are deleted from D-ACCOUNTS. Columns 32-37 are DELREC to name the EXCPT Name for the record to be deleted. Providing Security for TurboIMAGE Databases and Data Sets TurboIMAGE lets several users access a database simultaneously. To ensure that there will be no access conflicts, you should specify the security provisions in each RPG program. You can specify security at the database, data set or data record (item) level. There are two ways for doing this. You can specify that database and data set security be handled automatically by RPG. If you need more flexibility, you can provide this security by locking and unlocking databases or data sets yourself. The next two sections discuss automatic and manual locking and unlocking in detail. Automatically Locking and Unlocking TurboIMAGE Databases and Data Sets. To have RPG automatically lock and unlock a TurboIMAGE database, data set or data record, enter a locking mode in column 66 of the IMAGE File Description Continuation Specification. The locking modes that you can select are: Table 3-1. --------------------------------------------------------------------------------------------- | | | | Column 66 | Description | | | | --------------------------------------------------------------------------------------------- | | | | B | Lock the entire database when the program starts and unlock it when | | | the program ends. | | | | --------------------------------------------------------------------------------------------- | | | | S | Lock the data set when the program starts and unlock it when the | | | program ends. | | | | --------------------------------------------------------------------------------------------- | | | | 1 | Lock the entire database before a record is read, written or updated. | | | Unlock it after the record is read, written or updated. | | | | --------------------------------------------------------------------------------------------- | | | | 9 | Lock the data set before a record is read, written or updated. | | | Unlock it after the record is read, written or updated. | | | | --------------------------------------------------------------------------------------------- | | | | R | Lock the data record before it is read, written or updated. Unlock | | | it after the record is read, written or updated. | | | | --------------------------------------------------------------------------------------------- Figure 3-31 shows how to specify automatic locking and unlocking at the data record level for TurboIMAGE data sets (see line 2).
[]
Figure 3-31. Automatically Locking and Unlocking a TurboIMAGE Data Set Record Comments 1 This line defines the TurboIMAGE data set file, DACCOUNT. Column 15 is I to indicate that the TurboIMAGE file is input. Column 16 is C for CHAINed (random) access. 2 This line specifies that DACCOUNT is part of the MARKET database. Columns 54-65 identify MARKET as the TurboIMAGE database that is used. Column 66 is R to specify open mode with automatic locking and unlocking at the data record level. Column 67 is 5 to specify Input/Output Mode 5 - Chained Read. 3 This line defines the password for the database. Columns 54-65 contain LEVEL READER to specify the password READER. This password establishes a user class identification that permits read access to the database. 4 This line identifies the key field for the data set. Columns 54-65 contain ITEM NAME-LAST to specify that the key for the data set is NAME-LAST. 5 This line names the data set to be accessed. Columns 54-65 contain DSNAMED-ACCOUNTS to specify that the data set is D-ACCOUNTS. Manually Locking and Unlocking TurboIMAGE Databases and Data Sets. This section explains how you can control the locking and unlocking of TurboIMAGE databases and data sets. You use the LOCK and UNLCK operations in Calculation Specifications. Figure 3-30 through Figure 3-32 show how to lock and unlock databases, data sets and individual records in the data sets. The examples use the MARKET database whose schema is shown in the section titled "Defining a TurboIMAGE Database Schema." Figure 3-32 gives an example of adding records to the data set, D-ACCOUNTS. The entire database (MARKET) to which D-ACCOUNTS belongs is locked before a record is added. After the record is added, the database is unlocked.
[]
Figure 3-32. Manually Locking and Unlocking a TurboIMAGE Database Comments 1 This line defines the file, IDACCT. 2 This line defines the TurboIMAGE data set file, DACCOUNT. Column 15 is U to indicate that DACCOUNT is updated. Column 16 is C for CHAINed (random) access. Column 66 is A to indicate that records are added to DACCOUNT. 3 This line specifies that DACCOUNT is part of the MARKET database. Columns 54-65 identify MARKET as the TurboIMAGE database that is used. Column 66 is L to indicate user-controlled manual locking. Column 67 is C to specify chained sequential read mode. 4 This line defines the password for the database. Columns 54-65 contain LEVEL WRITER to specify password, WRITER. This password establishes a user class identification that permits write access to the database. 5 This line identifies the key field for the data set. Columns 54-65 contain ITEM ACCOUNT-NO to specify that the key for the data set is ACCOUNT-NO. 6 This line names the data set to be accessed. Columns 54-65 contain DSNAMEA-ACCOUNT-NO to specify that the data set is D-ACCOUNTS. 7 This line begins the input record description of the IDACCT file. 8 This line begins the input record description of the DACCOUNT file. 9 This line reads the data set, D-ACCOUNTS, randomly. Columns 18-27 contain ACTNO to specify the key field for reading the data set. Columns 28-32 contain CHAIN to specify a chained read operation. Columns 33-42 specify the name of the TurboIMAGE data set file, DACCOUNT. Columns 54-55 contain 80 to turn on indicator 80 when a record is not found for the account number in D-ACCOUNTS. Columns 56-57 contain the H0 indicator to avoid a compiler warning for the CHAIN operation. The end-of-chain indicator has no meaning since records are accessed randomly. 10 This line locks the database, MARKET, when indicator 80 is turned on. Columns 10-11 contain 80 to condition the LOCK operation. Columns 28-32 contain LOCK to specify the lock operation. Columns 33-42 contain DACCOUNT to identify the data set to lock. Columns 43-48 contain MARKET to identify the database to lock. You must enter both a data set (in columns 33-42) and a database in this field to enable locking for the entire database. Column 51 is 1 to specify the field length (always use 1). This prevents a compiler error. Columns 54-55 are blank to specify unconditional locking. If the database is already locked by another process, the program suspends until the database is unlocked. Columns 56-57 contain 11 for the low resulting indicator. An indicator is required in this field. When turned on, this indicator signals a memory manager error. Columns 58-59 contain 12 for the equal resulting indicator. An indicator is required in this field. When turned on, this indicator signals that the lock request was granted. 11 This line specifies that exception output is performed when indicator 0 is turned on. 12 This line unlocks the database, MARKET, when indicator 80 is turned on. Columns 10-11 contain 80 to condition the UNLCK operation. Columns 28-32 contain UNLCK to specify the unlock operation. Columns 33-42 contain DACCOUNT to identify the data set to unlock. Columns 43-48 contain MARKET to identify the database to unlock. Column 51 is 1 for the field length (always use 1). Columns 56-59 contain the same indicators used in line 10 and they function the same way. 13 This line specifies the output operation for adding records to the D-ACCOUNTS data set. Column 15 is E to identify this record as an exception record. Columns 16-18 are ADD to add records to the TurboIMAGE data set. Columns 32-37 are ADDREC to name the EXCPT Name for the record to be added. The following figure shows how to lock and unlock the data set, D-ACCOUNTS.
[]
Figure 3-33. Manually Locking and Unlocking a TurboIMAGE Data Set Comments 1 This line defines the file, IDACCT. 2 This line defines the TurboIMAGE data set file, DACCOUNT. Column 15 is U to indicate that DACCOUNT is updated. Column 16 is C for CHAINed (random) access. Column 66 is A to indicate that records are added to DACCOUNT. 3 This line specifies that DACCOUNT is part of the MARKET database. Columns 54-65 identify MARKET as the TurboIMAGE database that is used. Column 66 is L to indicate user-controlled manual locking. Column 67 is C to specify chained sequential read mode. 4 This line defines the password for the database. Columns 54-65 contain LEVEL WRITER to specify the password, WRITER. This password establishes a user class identification that permits write access to the database. 5 This line identifies the key field for the data set. Columns 54-65 contain ITEM ACCOUNT-NO to specify that the key for the data set is ACCOUNT-NO. 6 This line names the data set to be accessed. Columns 54-65 contain DSNAMEA-ACCOUNT-NO to specify that the data set is D-ACCOUNTS. 7 This line begins the input record description of the IDACCT file. 8 This line begins the input record description of the DACCOUNT file. 9 This line reads the data set, D-ACCOUNTS, randomly. Columns 18-27 contain ACTNO to specify the key field for reading the data set. Columns 28-32 contain CHAIN to specify a chained read operation. Columns 33-42 specify the name of the TurboIMAGE data set file, DACCOUNT. Columns 54-55 contain 80 to turn on indicator 80 when a record is not found for the account number in D-ACCOUNTS. Columns 56-57 contain the H0 indicator to avoid a compiler warning for the CHAIN operation. The end-of-chain indicator has no meaning since records are accessed randomly. 10 This line locks the data set, D-ACCOUNTS (DACCOUNT), when indicator 80 is turned on. Columns 10-11 contain 80 to condition the LOCK operation. Columns 28-32 contain LOCK to specify the lock operation. Columns 33-42 contain DACCOUNT to identify the data set to lock. Columns 54-55 contain 10 to specify that indicator 10 be turned on if the database, data set or a record in the data set is already locked by another process. You can enter a TurboIMAGE STATUS array in the File Description Continuation line to get additional information about the lock when indicator 10 is turned on. Columns 56-57 contain 11 for the low resulting indicator. An indicator is required in this field. When turned on, this indicator signals a memory manager error. Columns 58-59 contain 12 for the equal resulting indicator. An indicator is required in this field. When turned on, this indicator signals that the lock request was granted. 11 This line specifies that exception output is performed when indicator 80 is turned on (indicator 80 is turned on when a record is not found for an account number). 12 This line unlocks the data set, D-ACCOUNTS, when indicator 80 is turned on. Columns 10-11 contain 80 to condition the UNLCK operation. Columns 28-32 contain UNLCK to specify the unlock operation. Columns 33-42 contain DACCOUNT to identify the data set to unlock. Columns 56-59 contain the same indicators used in line 10 and they function the same way. 13 This line specifies the output operation for adding records to the D-ACCOUNTS data set. Column 15 is E to identify this record as an exception record. Columns 16-18 are ADD to add records to the TurboIMAGE data set. Columns 32-37 are ADDREC to name the GROUP Name for the record to be added. The following figure shows how to lock and unlock individual records in the D-ACCOUNTS data set.
[]
Figure 3-34. Manually Locking and Unlocking TurboIMAGE Data Set Records Comments 1 This line defines the file, IDACCT. 2 This line defines the TurboIMAGE data set file, DACCOUNT. Column 15 is U to indicate that DACCOUNT is updated. Column 16 is C for CHAINed (random) access. Column 66 is A to indicate that records are added to DACCOUNT. 3 This line specifies that DACCOUNT is part of the MARKET database. Columns 54-65 identify MARKET as the TurboIMAGE database that is used. Column 66 is L to indicate user-controlled manual locking. Column 67 is C to specify chained sequential read mode. 4 This line establishes write access to the database. Columns 54-65 contain LEVEL WRITER to specify write access to the database. 5 This line identifies the key field for the data set. Columns 54-65 contain ITEM ACCOUNT-NO to specify that the key for the data set is ACCOUNT-NO. 6 This line names the data set to be accessed. Columns 54-65 contain DSNAMEA-ACCOUNT-NO to specify that the data set is D-ACCOUNTS. 7 This line begins the input record description of the IDACCT file. 8 This line begins the input record description of the DACCOUNT file. 9 This line reads the data set, D-ACCOUNTS, randomly. Columns 18-27 contain ACTNO to specify the key field for reading the data set. Columns 28-32 contain CHAIN to specify a chained read operation. Columns 33-42 specify the name of the TurboIMAGE data set file, DACCOUNT. Columns 54-55 contain 80 to turn on indicator 80 when a record is not found for the account number in D-ACCOUNTS. Columns 56-57 contain the H0 indicator to avoid a compiler warning for the CHAIN operation. The end-of-chain indicator has no meaning since records are accessed randomly. 10 This line locks individual records in the data set, D-ACCOUNTS (DACCOUNT). Columns 18-27 contain ACTNO, which contains the key of the record to lock in DACCOUNT. Columns 28-32 contain LOCK to specify the lock operation. Columns 33-42 contain DACCOUNT to identify the data set to lock. Columns 54-55 contain 10 for the high resulting indicator. An indicator is required in this field. Columns 56-57 contain 11 for the low resulting indicator. An indicator is required in this field. Columns 58-59 contain 12 for the equal resulting indicator. An indicator is required in this field. 11 This line specifies that exception output is performed when indicator 80 is turned on (indicator 80 is turned on when a record is not found for an account number). 12 This line unlocks individual records in the data set, D-ACCOUNTS. Columns 18-27 contain ACTNO, which contains the key for the record to unlock in DACCOUNT. Columns 28-32 contain UNLCK to specify the unlock operation. Columns 33-42 contain DACCOUNT to identify the data set to unlock. Columns 54-55 contain 10 to specify the high resulting indicator. An indicator is required in this field. Columns 56-57 contain 11 to specify the low resulting indicator. An indicator is required in this field. Columns 58-59 contain 12 to specify the equal resulting indicator. An indicator is required in this field. 13 This line specifies the output operation for adding records to the D-ACCOUNTS data set. Column 15 is E to identify this record as an exception record. Columns 16-18 are ADD to add records to the TurboIMAGE data set. Columns 32-37 are ADDREC to name the GROUP Name for the record to be added.


MPE/iX 5.0 Documentation