Professional Documents
Culture Documents
ADABAS and NATURAL Presentation
ADABAS and NATURAL Presentation
ADABAS and NATURAL Presentation
Day-1 Day-3
Database Concepts ADBAS Nucleus
ADABAS Overview ADAPREP commands
ADABAS Architecture
Day-4
Day-2 – ADABAS programming
Fields & Descriptors
Accessing ADABAS Day-5
Data Protection/Security – Test the knowledge
Database Concepts
A data base is not really anything new. It is just a concept, or a way of organizing
data and software, to solve some of the problems found in conventional file
processing.
PROGRAM - A
INDEPENDENT
FILE SYSEM
PROGRAM - B
This redundancy could cause problem when customer address changes. The address must be changed in
each of the files causing duplication of effort and more opportunities of errors.
So it is better for different application systems to share same centralized database thus avoiding
the data redundancy.
POS
CENTRALIZED
CRS DATA BASE
ARS
Maintaining accuracy (integrity) of the data is very important in a database system because the
database is shared by many users.
Without integrity, the data could end up to be invalid or unreliable.
Everyone who uses the database, from programmer to DBA, is responsible for integrity of
data.
INCREASE INDEPENDENCE
REDUCE REDUNDANCY
MAINTAIN DATA INTEGRITY
INCREASE DATA SECURITY
– HIERARCHICAL
– NETWORK
– RELATIONAL
HIERARCHICAL Database
STUDENT
REPORTS
COURSES COMMENTS
HIERARCHICAL Database
In a Hierarchical database…
NETWORK Database
COMPANY CLUB
NETWORK Database
RELATIONAL Database
In a Relational Database, fields in one record type are used to point to other
record types
ADABAS Database
Which type of data base management system do you think ADABAS is closest to?
RELATIONAL
ADABAS Overview
Adabas is available for a wide range of platforms, including Windows NT, UNIX, Open VMS and
mainframe.
Access to Adabas
– Adabas can be accessed from Natural, Software AG’s 4GL development environment,
– Bolero, Software AG’s application factory, and from every 3GL and 4GL that is equipped with a call
interface.
– In addition, Adabas can be accessed via standard interfaces such as ODBC or JDBC and, of course,
embedded SQL can be used
ADABAS
What is a Descriptor
When Key is defined, nothing is changed in the data, Instead an inverted list is built for that
key (Descriptor).
Which field you want to describe as Descriptor
LICENSE TYPE MODEL COLOR
Inverted List Based on LICENSE
Features of ADABAS
Another feature of ADABAS is the ability to produce many different views of the data (using
PREDICT / NATURAL)
Advantages of User Views are -
– Provides security for confidential data
– Provides simple views to the users
– Eliminates unnecessary information being presented
– Data Compression
Allows data to be stored efficiently
– Security Facilities
Provided for confidentiality of data
Data Compression
ADABAS has an option to store data on the disk in a compressed form. This option saves disk
space and reduces I/O.
– Security by Value
• Access to a file can be restricted by the value of the field. For example, managers could be
restricted to personal information of employees in only their own department.
– Ciphered Data
• Records can be ciphered or encrypted when information is highly confidential. A ciphering key
is entered by the user when records are stored. It must be entered again to access the data.
– Multi-User
– Singe-User
Multi-User
• This is the normal operation of a data base where many people in an organization are reading,
updating, adding and deleting data simultaneously.
Operating System
ADABAS
DATABASE ADABAS Nucleus
Multi Processing Module
---------------------------
MPM Batch program
Application - 2
Single User
This mode can be used when there is huge amount of processing (like rearranging the
entire database). This could be done at night when no one else wants to use Adabas.
Operating System
ADABAS
DATABASE
ADABAS Nucleus
Application - 1
Application - 2
ADABAS Architecture
ADABAS Database
Associator
Work
Data
ADABAS
Database
– The Address Converter is an index to the physical storage location of the records, giving the physical
block in which each record is stored.
– There is one Address Converter for every dataset in the database.
To understand how the Address Converter works, we need to know how the data records are
organized
This dataset is used to keep data protection information that is required for automatic restarts and backouts
after a system failure
It acts as a type of working scratch-pad area for ADABAS
– Besides storing DATA PROTECTION INFORMATION, the WORK dataset acts as temporary
storage during a SEARCH command. The WORK dataset also acts as temporary storage for ISN
lists
– When ADABAS is finding records for you, it uses the WORK dataset for intermediate results
– Only partial or incomplete transactions are kept track of here. A log of the commands is not kept in
the WORK dataset
The DATA dataset contains the physical data stored in FIXED SIZE BLOCKS
Address
Inverted List Block 1
Converter
Block 2 DATA
Block 3
WORK
ASSOCIATOR
After knowing the datasets let’s see the two optional logs of ADABAS
These are
– COMMAND LOG
– PROTECTION LOG
The Command Log keeps a record of every command that goes through the ADABAS nucleus
– This log gives a basis for billing those who use the system
– The log gives the valuable information for performance tuning
– This log is also used for application program debugging
The Protection Log contains before and after images of any records that are updated, deleted,
or added between checkpoints
– It is used for regeneration of the database
• (eg. After a disk crash)
– It is also used for backing out of a job
– It is used for keeping an audit trail
After knowing the ADABAS environment , let’s see the organization of data in the database
We will look at
– Datasets
– Records
– Fields
MU fields
This is a single dimensional array where ADABAS allows us to store multiple values in that
particular field. For example let’s look at the following typical employee record
If now we need Rajeev’s record of positions before his attaining the current Consultant
designation we may use an MU Field to store this information
Assc Const
Asst Const
This designation field constitutes an MU Field. The maximum numbers of occurrences supported are
191.
PE Fields
PE is a group of fields that repeat together in a record. A PE field can consist of elementary fields as well as
Multiple Value fields. For example I want to store the following details about car
-Car Number
-Model
-Type
-Servicing Dates
All this information can be stored in a PE field consisting of elementary fields as Number, Model and Type and
a Multiple Value field Service Date. A PE field can store up to 191 occurrences. Maximum of 99 PE group
occurrences per PE
Fields
&
Descriptors
1 - 255 Datasets
1 - 926 fields
ADABAS keeps track of field-related information in the Field Definition Tables (FDT)
Here is some of the information that is kept:
_ ADABAS field name
_ Format
_ Level
_ Length
_ Type of compression
_ Type of field
Data Format of fields
Data in an ADABAS is in one of the 6 following formats, each with a one letter code
The information about each field in the database is kept in the FDT (Field Definition Table)
Sample information of FDT looks like ...
EMPLOYEE-NO A1
NAME A2
LAST-NAME A3
FIRST-NAME A4
DEPARTMENT BB
RBC Induction - Proprietary and Confidential
FDT Information
01 P 4
01
02 A 16
02 A 16
01 P 10
=================================================================================
¦¦ FI ¦¦ Default ¦¦ NU
¦
================================================================
¦ ¦ ¦ No length bytes ¦ ¦ A length byte is ¦ ¦ One byte is use ¦
¦ ¦ ¦ are added. ¦ ¦ added at the ¦ ¦ to count empty ¦
¦ ¦¦ ¦ ¦ start of every ¦ ¦ fields. ¦
¦ ¦¦ ¦ ¦ field. ¦¦ ¦
¦ ¦¦ ¦¦ ¦ ¦ Fields with data ¦
¦ ¦¦ ¦¦ ¦ ¦ in them have a ¦
¦ ¦¦ ¦¦ ¦ ¦ length byte ¦
¦ ¦¦ ¦¦ ¦ ¦ added. ¦
================================================================================
+-----------------------------------------------+
¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ B ¦ A ¦ R ¦ B ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
+-----------------------------------------------+
+-------------------+
¦ The length of ¦ ¦ ¦ ¦ ¦ ¦
¦ '5' counts the ¦ 5 ¦ B ¦ A ¦ R ¦ B ¦
¦ characters and ¦ ¦ ¦ ¦ ¦ ¦
¦ includes itself. +-------------------+
3 2 S A M S
9 3 2 S A M S
+---------------------------+
¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ 0 ¦ 0 ¦ 0 ¦ 2 ¦ 8 ¦ 4 ¦ 6 ¦
¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
+---------------------------+
+-------------------------------------------------------+
¦ Default or NU compression would store this as packed, ¦
¦ remove the leading zeroes and add a length byte. ¦
+-------------------------------------------------------+
________________________________________________________
+---------------+
¦ ¦ 0 ¦ 8 ¦ 6 ¦
¦ 4 ¦ 2 ¦ 4 ¦ C ¦
+---------------+
This 7 byte field is compressed into only 4 bytes. The 'C' on the end indicates the sign of the number
(positive).
J E R R Y 0 0 0 0 0 0 0 0 0 2 8 4 6
1 2 3 4
6 J E R R Y 5 0 4 4 0 3 0 8 6
4 2 4 C
6JERRYC 086
4424C
Regular Descriptor:
A regular descriptor is a regular field that can be used for search criteria.
Example:
– In a file of employee records, the employee number would likely be defined as a regular
descriptor
A special feature of regular descriptors is the UNIQUE DESCRIPTOR option. This
ensures that there will be only one occurrence of each value in the data base dataset.
Example:
– If all employee numbers are to be unique, the unique descriptor option could be used for
the employee number field.
– The telephone companies use a phonetic descriptor for looking up names and phone numbers in
directory assistance.
Hyper Descriptors
Hyper-descriptors enable descriptor values to be generated based on a user-supplied algorithm.
– Example:
• If sales personnel wanted to look up customer records in reverse collating sequence in terms of
latest sales date, they could use a hyper-descriptor.
Compression of records has an effect on the inverted lists built for each descriptor.
For regular descriptors, null suppression will not find records when a search is conducted for a
zero value or a blank value.
No entry is made in the inverted list for a null value field under NU compression
The effects of NU compression for regular descriptors also applies to sub-descriptors and
phonetic descriptors.
Further, the NU compression also affects super-descriptors.
If any component of a super-descriptor is a zero or a blank under NU compression, the ISN for
that record will not be listed in the inverted list
Here is how to handle this:
– If zero or blank values may be meaningful in a descriptor field, use default compression.
– If zero or blank values are definitely not meaningful, it is fine to use NU compression
Accessing
ADABAS
You may access data in an ADABAS database using one of two approaches
READ PHYSICAL
– In this method sequential access is to read in the physical order that the records are stored
Physical Order - READ PHYSICAL
ISN EMPNO LAST FIRST DEPT
NAME NAME
1 01037 HARRIS JILL PROD
7 15429 BULWARK KEN ACCT Employee Dataset
5 66725 GUNNER DOUG PROD
3 41180 CONCH TERRY ADMIN
6 31622 WU MATT MIS
4 09331 HOYTE BRIAN PROD
A READ PHYSICAL command will read the records in the order in which they are stored in
the dataset.
So the records will be read in this order:
1 7 5 3 6 4 . . .
READ Physical
The first method for sequential access is to read in the physical order that the records are stored. A READ
PHYSICAL command will read the records in the order in which they are stored in the dataset.
A second method for sequential access is to read in the order of the ISN.
A READ by ISN will retrieve the records in ISN order
So the records will be read in this order:
1 2 3 4 5 6 7 . .
READ BY ISN :A second method for sequential access is to read in the order of the ISN
A READ by ISN will retrieve the records in ISN order
The records will be read in this order: 1 2 3 4 5 6...
The third method for sequential access is to read in the order of ISNs of the Inverted Lists
A READ LOGICAL will retrieve records in the order of listing in one of the Inverted Lists
A READ LOGICAL by DEPT will be in this order
2 7 17 19 . . . 3 8 11 14 . .
The third method for sequential access is to read in the order of
ISNs listed in one of the Inverted Lists. A READ LOGICAL will retrieve records in the
order of listing in one of the Inverted Lists.
A READ LOGICAL by DEPT will be in this order:
2 7 17 19 . . . 3 8 11 14 . .
FIND - Simple
Employee Dataset
+-------------------------------
Inverted List for DEPT. ¦ ¦ ¦ LAST ¦FIRST¦
+------------------------- ¦ISN¦EMP. NO¦ NAME ¦NAME ¦ DEPT
¦VALUE ¦COUNT¦ ISNs +---+-------+-------+-----+-----
+------+-----+------------ ¦ 1 ¦ 01037 ¦HARRIS ¦JILL ¦ PROD
¦ACCT ¦ 30 ¦2,7,17,19... ¦ 7 ¦ 15429 ¦BULWARK¦KEN ¦ ACCT
¦ADMIN ¦ 14 ¦3,8,11,14... ¦ 5 ¦ 66725 ¦GUNNER ¦DOUG ¦ PROD
¦MIS ¦ 7 ¦6,10,18,34.. ¦---+-------+-------+-----+-----
¦PROD ¦ 52 ¦1,4,5,9..... ¦ 3 ¦ 41180 ¦CONCH ¦TERRY¦ ADMI
+------------------------- ¦ 6 ¦ 31622 ¦WU ¦MATT ¦ MIS
¦ 4 ¦ 09331 ¦HOYTE ¦BRIAN¦ PROD
If a simple FIND command is given ¦---+-------+-------+-----+-----
¦ : ¦ : ¦ : ¦ : ¦ :
FIND ALL RECORDS WITH DEPT = ADMIN
the following ISNs would be selected: 3 8 11 14 . . .
RBC Induction - Proprietary and Confidential
FIND - Complex
Complex FINDs involve searching based on more than one descriptor. Complex FINDs
involve more processing.
– EXAMPLE:
• FIND ALL RECORDS WITH
EMPNO < 50000 AND DEPT = PROD
ISNs where ISNs where
EMPNO < 50000 DEPT = PROD
::::::::: :::::::::
::::::::: :::::::::
:::::::::
:::::::::
A list of the selected ISNs is produced for each search parameter given. The lists are then merged
into one list where both conditions are true .
¦41189 ¦ 1 ¦ 3 1,4
¦66752 ¦ 1 ¦ 5
+-------------------------
13
RBC Induction - Proprietary and Confidential
9 6 8
GET - Using a specific ISN
GET using specific ISN is the last method for accessing ADABAS records in random order
This can be used to access specific records where the ISN is already known
In some ADABAS data bases the ISNs are given extra meaning.
– For example: The ISNs could be used as the 5-digit employee number in a Personnel data base. Then
instead of using a command like
• FIND ALL RECORDS WITH EMPNO = 23845
you could use a command like
• GET ISN 23845 .
By setting up the data base this way, disk space is saved. (One field is saved in the dataset)
By using the GET command instead of a FIND, processing time and I/O will be saved
Apart from the above ADABAS has other access command like
– UPDATE
– DELETE
– ADD
ADABAS can be accessed with the following access facilities
– DIRECT CALLS
– ADABAS SQL
– NATURAL
– ADAPREP
DIRECT CALLS
The Direct Calls from application programs use 2 character codes for commands
Here are some commands used in direct calls
S1 - FIND
L2 - READ PHYSICAL
L3 - READ LOGICAL
N1 - ADD A NEW RECORD
E1 - DELETE A RECORD
Using direct calls is like programming in a low-level language.
With each command, control blocks and buffers must all be identified
Because of the detail involved, direct calls are rarely used. Occasionally a Systems
Programmer may use direct calls for some special purpose
ADABAS SQL
ADABAS SQL contains a subset of standard SQL, as well as extensions which are not
available within standard SQL.
ADABAS SQL relieves the user from having to define the data base's data areas manually, and
takes over data transfer to the program data areas automatically.
NATURAL
NATURAL is a powerful application programming language that is designed for accessing
ADABAS data bases.
NATURAL commands are easy to understand and use. Here are some examples
FIND UPDATE
GET DELETE
READ
NATURAL programs can be either batch or on-line.
NATURAL can also be used for simple ad-hoc inquiries, for reports, and for complex
programs updating, deleting and adding records.
Programmers can save many lines of code using NATURAL instead of PL/I or COBOL with
ADABAS SQL or direct calls.
NATURAL has automatic error handling built-in, and includes a user-friendly development
environment.
A command to find ISNs that match certain criteria can be done in NATURAL, ADABAS
SQL, or by direct calls.
NATURAL takes about 1 line of code.
ADABAS SQL takes about 10 lines of code.
Direct Calls take about 25 lines of code.
Data Protection
Security
Data protection must be built into a Data Base Management System to ensure that the data
base retains its integrity.
– Let's examine a situation where data integrity could easily be lost.
• When preparing a packing slip on-line for items to be sent to a customer, the customer record is
accessed and many item records are accessed and updated
Packing Slip Transaction
Data Integrity loses If this logical transaction is not updated in database then
If a machine failure occurs, the back-out (BT) occurs automatically when the database is
brought up again
When records are being updated the record is "held". This means that no other program can
access that record for updating.(Use of this "hold" logic ensures accurate data integrity)
The third situation is when the transaction time limit is exceeded. If two programs request
records that are being held by each other, a deadlock situation will occur.
When the transaction time limit is reached, the transaction will be backed out
A transaction may be backed out for one of three reasons we've discussed.
– Machine failure
– Non-activity time limit
– Transaction time limit
PREDICT
+--------------------------------------------------------------+
¦ The dictionary maintains information about ¦
¦ the data base, its datasets and fields. ¦
+--------------------------------------------------------------+
+--------------------------------------------------------+
¦ Details kept about the fields include: ¦
¦ _ name ¦
¦ _ format ¦
¦ _ length ¦
¦ _ descriptor status ¦
¦ _ repeating group information ¦
¦ _ compression ¦
+--------------------------------------------------------+
When a data base is first loaded, the elements of the datasets must be defined indicating the
characteristics of each field.
– COBOL programs use the WORKING-STORAGE SECTION of the COBOL program to define
variables used in the program.
– PL/I programs have DCL (declare) statements to define variables used in the programs.
– NATURAL programs use Data Definition Modules (DDMs) to define their variables.
The data dictionary is used to store the definitions for the variables that will be used in the
COBOL, PL/I or NATURAL programs
PREDICT can also be used to create reports cross-referencing fields, datasets and programs
+---------------------------------------------------------------------------+
¦ ACCESS/UPDATE LEVELS ¦
¦--------------------------------------------------------¦
¦ ¦ ¦ EMPLOYEE ¦ PROJECT ¦ AUTOMOBILE ¦
¦ NAME ¦ PASSWORD ¦ DATASET ¦ DATASET ¦ DATASET ¦
¦-----------+----------+----------+---------+---------------------------------------------------¦
¦ J. BROWN ¦ HAT ¦ 14/8 ¦ 14/8 ¦ 10/5 ¦ ----+
¦ S. STEELE ¦ STOL ¦ 10/6 ¦ 10/5 ¦ 14/9 ¦ ¦ |
¦ ¦ ¦ ¦ ¦ ¦ ¦ |
+--------------------------------------------------------------+
+----------------------------------------------+ ¦ ¦ +----------------------------------------------+
¦ Sam Steele has access level ¦ ¦ ¦ From this table, what are Joan ¦
¦ 10 for the employee dataset. He +--+ ¦ Brown's access and update levels ¦
¦ has level 6 update privileges ¦ ¦ for the automobile dataset? ¦
¦ on this file. ¦ ¦ ¦
+----------------------------------------------+ ¦ Access ¦
¦ Update ¦
+---------------------------------------------------+
ADABAS
NUCLEUS
For each ADABAS database there an ADABAS nucleus which resides in its own partition and
responsible for all database requests by application programs
It handles control of concurrent access and update (online transactions), buffering of database
records, back out and recovery in case of system crashes
ADABAS Buffers
ADABAS maintains following buffers while accessing the database
CONTROL BLOCK
SEARCH-BUFFER
VALUE-BUFFER
FORMAT-BUFFER
RECORD-BUFFER
ISN-BUFFER
CONTROL BLOCK
– Contains Command-ID
– Database and File-ID’s
– Return codes
SEARCH BUFFER
– Contains the names of the descriptors by which the search is made along with the search criteria
VALUE BUFFER
– Contains descriptor names used for search criteria
– Value supplied dynamically for complex search
FORMAT BUFFER
– List of the fields one wants to retrieve
– Can be specified in any order
• (independent of physical location)
RECORD BUFFER
– After retrieving the record the data values of the requested fields are kept here
– Arranged in the order as specified in FORMAT buffer
ISN BUFFER
– List of the ISN’s resulting from a successful FIND operation
ADASAV
A utility to dump database datasets onto tape or disk and retrieve them again.
ADARES
A utility to reapply or remove updates to the database using the protection log facilit y.
ADACMP
A utility to compress and decompress the datasets.
ADALOD
A utility to load compressed data into database.
ADAULD
A utility to unload data from database to a dataset .
ADAORD
This utility has many options:
Reorder the Associator for 1 or more datasets
Reorder data storage for 1 or more datasets
Unload 1 or more datasets for relocation to another device.
ADADBS
To modify the characteristics of an ADABAS dataset, ADADBS may be used. Here
are some:
Delete a dataset
Recover unused space in the data base
Increase the size of a data base
Rename or renumber datasets
Change the length of a field
Add new fields to the dataset
Release a field from being a descriptor
ADAINV
The INVERT function of ADAINV creates a descriptor, sub descriptor, super
descriptor, hyper descriptor, phonetic descriptor.
ADAREP
Which datasets are in database
The size of each dataset
Physical space usage
Field definition table information
101
RBC Induction - Proprietary and Confidential
DESCRIPTION OF NATURAL STATEMENTS
• Data Definition
• Data Access
• Data Manipulation
• Data Modification
• Data Reporting
• Loop Execution Statements
• Screen Statements
• Logical Check Statements
• Routine Invoking Statements
• File Control Statements
102
RBC Induction - Proprietary and Confidential
NATURAL STATEMENTS
This statement along with its closing structure END-DEFINE explicitly defines the data area.
It must be the first statement in a program.
Only comment lines can be placed before DEFINE DATA statement.
All fields (Database fields as well as user-defined variables) are defined in this statement
The fields can be defined either inside the defined data segment or outside. When it is defined
out side it is defined in
1.Local data area LDA
2.Global data area GDA
3.Paramater data area PDA
103
RBC Induction - Proprietary and Confidential
NATURAL STATEMENTS
104
RBC Induction - Proprietary and Confidential
USER-DEFINED VARIABLES
105
RBC Induction - Proprietary and Confidential
USER-DEFINED VARIABLES
Variables Initialization:
The default initial value for various formats is
B,F,I,N,P 0
A Blank
L F(alse)
D D''
T T'00:00:00'
C (AD=D)
Used within the DEFINE DATA statement to indicate the structure and grouping of the
definitions.
–Relevant to view definitions, redefinition's and field groups.
–Range from 1 to 9.
–Generally, variable definitions are on level 1.
–The level numbering in view definitions, redefinitions, and groups must be sequential.
No level numbers may be skipped.
–If you redefine a field, the REDEFINE option must be on the same level as the original
field, and the fields resulting from the redefinition must be one level lower.
106
RBC Induction - Proprietary and Confidential
Group Fields
107
RBC Induction - Proprietary and Confidential
Group Fields
The fields #EMPNO, #BIRTH, EMPADDR are defined under the common group name
#GEMP. #GEMP only serves as a group name and is not a field in its own and
therefore does not have a format/length definition
ARRAYS
Single dimensional array
DEFINE DATA LOCAL
1 #ARRAY (A10/1:3)
END-DEFINE
108
RBC Induction - Proprietary and Confidential
DATABASE VIEWS
109
RBC Induction - Proprietary and Confidential
DATA ACCESS / MODIFICATION STATEMENTS
110
RBC Induction - Proprietary and Confidential
READ
111
RBC Induction - Proprietary and Confidential
FIND
The FIND statement is used to select a set of records from the database based on a
search criterion consisting of fields defined as descriptors (keys). Various relational
operators like (EQ, GT, LT, LE, GE, NE) or (=, >, >=, <, <=, =) are used along with
clause to filter the records
************************************************************************
DEFINE DATA LOCAL
1 MYVIEW VIEW OF EMPLOYEES
2 PERSONNEL-ID
2 NAME
2 JOB-TITLE
2 CITY
END-DEFINE
*
FIND MYVIEW WITH CITY = 'PARIS'
WHERE JOB-TITLE = 'INGENIEUR COMMERCIAL'
DISPLAY NOTITLE CITY JOB-TITLE PERSONNEL-ID NAME
END-FIND
END
112
RBC Induction - Proprietary and Confidential
GET
A GET statement presents a single record for processing when the ISN is known. Unlike
READ and FIND, there is no associated processing loop
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
2 NAME
2 SALARY (1)
END-DEFINE
*
RD. READ EMPLOY-VIEW BY NAME
DISPLAY EMPLOY-VIEW
IF SALARY (1) > 1500000
/*
GE. GET EMPLOY-VIEW *ISN (RD.)
/*
WRITE '=' (50) 'RECORD IN HOLD:' *ISN(RD.)
COMPUTE SALARY (1) = SALARY (1) * 1.15
UPDATE (GE.)
113
RBC Induction - Proprietary and Confidential
STORE
STORE inserts/adds one record to a database file. One has to populate the data
fields with relevant values of the record before STORing it with the file.
DEFINE DATALOCAL
1 #CLIENT-ID (N8)
1 #CNAME (A20)
1 RECEVIEW VIEW OF RECEIVABLE
2 CLIENT-ID
2 CNAME
END-DEFINE
INPUT #CLIENT-ID #CNAME
RECEVIEW .CLIENT-ID := #CLIENT-ID
RECEVIEW .CNAME := #CNAME
STORE RECEVIEW
END TRANSACTION
114
RBC Induction - Proprietary and Confidential
UPDATE
UPDATE modifies one existing record with a database file. One has to select the particular
record by using READ/FIND/GET statement before updating the record. If we READ/FIND a
number of records before UPDATing one particular record, then all the records selected by
READ/FIND get locked. To avoid this, GET can be used to select the record we want to
update so that, only that record gets locked.
Example
DEFINE DATA
1 RECEVIEW VIEW OF RECEIVABLE
2 SALARY
END-DEFINE
RD1.
READ RECEVIEW WHERE SALARY GT 10000
IF SALARY EQ 14900
GET-REC.
GET *ISN(RD1.)
ADD 100 TO RECEVIEW .SALARY
UPDATE (GET-REC.)
END-IF
END TRANSACTION
END
115
RBC Induction - Proprietary and Confidential
DELETE
DELETE physically removes records from a database file. Before deleting the particular
record, one has to select the record by using READ/FIND/GET statement.
DEFINE DATA
1 RECEVIEW VIEW OF RECEIVABLE
2 ACTIVE
END-DEFINE
GET-REC.
READ RECEVIEW WHERE ACTIVE=FALSE
DELETE (GET-REC.)
END TRANSACTION
END
116
RBC Induction - Proprietary and Confidential
HISTOGRAM
The HISTOGRAM statement is used to either read only the values of one database field, or
determine the number of records which meet a specified search criterion.
DEFINE DATA LOCAL
1 MYVIEW VIEW OF EMPLOYEES
2 CITY
END-DEFINE
*
LIMIT 8
HISTOGRAM MYVIEW CITY STARTING FROM 'M'
DISPLAY NOTITLE CITY 'NUMBER OF/PERSONS' *NUMBER *COUNTER
END-HISTOGRAM
END
RESULT:
CITY NUMBER OF PERSONS CNT
-------------------- ----------- -----------
MADISON 3 1
MADRID 41 2
MAILLY LE CAMP 1 3
MAMERS 1 4
MANSFIELD 4 5
117
RBC Induction - Proprietary and Confidential
Data Definition Module
Natural screen
prints sample
120
RBC Induction - Proprietary and Confidential
THE END