M204 Concepts
M204 Concepts
M204 Concepts
Model 204
Model 204 is a registered trademark of
Computer Corporation of America,
Massachusetts.
Model 204
terabytes of data,
millions of rows,
thousands of concurrent users,
open connectivity,
secure environments,
and almost instant response to complex
queries.
Model 204
Model 204
Features - Procedures
1.
2.
3.
4.
5.
Section1
Relevant Data
Structures
Binary Tree
Binary Tree
Binary Tree
Binary Tree
Binary Tree
Pre-Order Transversal
Binary Tree
In Order Transversal
Binary Tree
Post-Order Transversal
Hashing
Files
Name = Smith,
John
SSN = 9963463689
Emp ID = 42134
DIVISION = Sales
SALARY = 22500
2nd
3rd
Emp ID = 42166
Records
Collection of Fieldname = Value Pairs
Each record is automatically assigned a unique
internal record number that is used by the
system to build index entries for the record.
A Sample record:
Name = Smith, Tom
SSN = 123456789
Emp ID = 42134
DOB = 56071
DIVISION = Sales
SALARY = 36500
Records
Records
Model 204 optimizes the relational model by,
incorporating embedded tables.
Employee skill
is an example
of a repeating
field since
employees can
have multiple
skills and the
number of skills
varies for each
Fields
Fields
Fields
Embedded blanks
Fields
File Group
File Group
Claims 95
MPSCCASE
MPSHCCS
MPSECCS
MPSWCCS
MPSOCCS
Claims
MPSCASM
MPSHCASE
MPSHHCS
MPSEHCS
MPSWHCS
MPSOHCS
MPSICASM
MPSICASE
Claims 96
MPSHICS
MPSEICS
MPSWICS
MPSOICS
Table A
field names,
values of FEW-VALUED fields, and
values of MANY-VALUED fields.
Table B
Table C
Table D
Table D also stores the Ordered Index Btree node pages, which contain the
values and record accessing information
for all ORDERED fields.
Types of Files
Entry Ordered
Types of Files
Unordered
the space freed by deleted records can
be reused when new records are
added.
Types of Files
Sorted
Types of Files
Hash Key
Types of Files
Hash Key
Procedure Storage
Permanent Procedures (routines) are
stored in Model 204 Files in the Table
D section of the file.
Field Attributes
Field Attributes
Representational Attributes
storage)
(data
Representational Attributes
VISIBLE, INVISIBLE
STRING (default)
FLOAT
BINARY
CODED, NON-CODED
FEW-VALUED, MANY-VALUED
OCCURS
LENGTH
PAD
Operational Attributes
DEFERRABLE, NON-DEFERRABLE
AT-MOST-ONE, REPEATABLE
Level
Restrictions
equal to,
less than,
greater than,
or between
retrievals quickly.
fieldname IS value
fieldname IS EQ (=) value
fieldname IS LESS THAN (LT or <) value
fieldname IS GREATER THAN (GT or >) value
fieldname IS BETWEEN (GT or >) value AND (LT
or <) value
fieldname IS GREATER THAN (GT or >) value
AND LESS THAN (LT or <) value
fieldname IS LESS THAN (LT or <) value AND
GREATER THAN (GT or >) value
Section 2
Request Structure
Requests can
Request Structure
Request Structure
Request Structure
BEGIN
GET.RECS: FIND ALL RECORDS FOR WHICH
CITY = SAN DIEGO
TOTAL PREMIUM IS GREATER THAN 200
AGENT = KESSLER OR WAGNER
END FIND
FOR EACH RECORD IN GET.RECS
PRINT FULLNAME WITH AGENT AT COLUMN 30
END FOR
END
Implied AND
RECS: FIND ALL RECORDS FOR WHICH
MAKE = FORD AND COLOR = BLUE OR COLOR = RED
END FIND
Labels
Statement Blocks
Statement Blocks
END BLOCK closes all open blocks and
returns the nesting level to the level
of the label that is being ended.
END BLOCK is particularly useful when
several types of block statements
are nested within each other.
Line Continuation
Variables
Variables
%Variables
Global Variables
Fieldname Variables
Arrays
Image Item Variables
Screen Item Variables
What is a %Variable
Value:
255 Chars.
Variable Declaration
Variable Declaration
(contd.)
Implicit Declaration
BEGIN
Variable Parameters
VTYPE
VLEN
VDP
=
=
=
STRING
20
0
Variable Declarations
FIXED variables
FLOAT variables
Precision is guaranteed to 15
decimal digits. The exponent must
be between 75 and -74.
%X IS FLOAT
%X = 0.999999999999997E-73
STRING variables
Yields:
1.2
1.23
1.234
STRING variables
Conversions In Calculations
BEGIN
%X IS STRING
%Y IS FIXED
%Z IS STRING
%X = 7
%Y = 9
%Z = %X * %Y
PRINT %Z
END
Conversions In Calculations
Global Variables
Located in Global variable table of user's server
Value set with $SETG function
Value retrieved with $GETG function
Value can be used with Dummy Strings (?& prefixed)
Evaluated at compile time
Global Images and Screens can be used
Is accessible only by setting user and lasts until end
of terminal session
?&MFILE
BEGIN
BEGIN
%A = 'TOYOTA' %MAKE = $GETG('MAKE')
%X = $SETG('MAKE',%A)
FD: IN VEHICLES FD
END MAKE = %MAKE
END
CLOSE ?&MFILE
BEGIN
%FIELDNAME = CITY
FD1: IN CLIENTS FDLDNAME
END FIND
= DUNEDIN
Arrays
BEGIN
%SALES.TOTALS IS STRING LEN 10 ARRAY(12)
%X IS FIXED
FD: IN SALES FD
RECTYPE = MONTHLY
END FIND
FR FD
%X = %X + 1
%SALES(%X) = MONTHLY SALES TOTAL
END FOR
END
Commands and
Statements
Commands:
level
Executed at command
Executed immediately
Not compiled
Statements:
User Language
instructions
Executed when
request is executed
Compiled
Basic Commands
Login :
Open :
Basic Commands
Logout :
Close :
Close All:
IS PRESENT
IS NOT PRESENT
Boolean Logic
AND
OR
NOT
NOR
Boolean Logic
Order of precedence Operator
NOT
NOR
AND (explicitly stated)
OR
AND (implied by a new line)
Retrieval Attributes
Equality Retrievals
Equality Retrievals
Equality Retrievals
Less than
<
LT
Greater than >
GT
Less than or equal to
<= LE
Greater than or equal to >= GE
Pattern Matching IS LIKE 'PATTERN'
Pattern Matching
Special Characters used to represent
values in search criteria
Wildcard
Place holders
Numeric
Character
Generic
Or
#
@
+
,
SMITHSON
SMITHTON
SMITHSONIAN
SMITH
DATE
DATE
DATE
DATE
OF
OF
OF
OF
BIRTH
BIRTH
BIRTH
BIRTH
=
=
=
=
391103
391107
3911234
391145
SMITHSON
SMITHTON
but not
SMITHLON
FIND Statement
FIND Statement
Counting Records
FD: IN VEHICLES FD
MAKE = FORD
MODEL = MUSTANG
END FIND
CT: COUNT RECORDS IN FD
PRINT COUNT IN CT
IN VEHICLES FPC
END FIND
Index Loops
Used for looping when a looping
variable is needed
IF statement
IF Statement
IF %A = 1 THEN
PRINT 'A IS ONE'
END IF
IF Statement (contd.)
IF %A EQ 1 THEN
PRINT 'A IS ONE'
ELSE
PRINT 'A IS NOT ONE'
END IF
IF Statement (contd.)
IF %A EQ 1 THEN
IF %B EQ 1 THEN
PRINT 'A IS ONE AND B IS ONE'
ELSE
PRINT 'A IS ONE AND B IS NOT ONE'
END IF
ELSE
PRINT 'A IS NOT ONE'
END IF
IF Statement (contd.)
IF %A = 1 THEN
PRINT 'A IS ONE'
ELSEIF %A = 3 THEN
PRINT 'A IS THREE'
ELSE
PRINT 'A IS INVALID'
END IF
JUMP TO Statement
B
...
...
JUMP TO END.PGM
...
END.PGM: END
END
NOTE Statement
B
VLOOP : FD
END FIND
FRLOOP : FOR EACH RECORD IN VLOOP
MODEL: NOTE CAR.MODEL
MODEL.MATCH: FD IN MFILE204
CAR.MAKE = VALUE IN MODEL
END FIND
END FOR
END
Print Statement
WITH - pointer moved to next position
AND- pointer moved 2 positions to leave a
blank
Positioning:
AT Left Justifies
TO Right Justifies
PRINT NAME AT 15
PRINT SALARY TO 45
REPEAT Statement
REPEAT WHILE
REPEAT X TIMES
REPEAT FOREVER
REPEAT WHILE
REPEAT WHILE %X < 40
.
%X = %Y * %Z
.
END REPEAT
REPEAT X TIMES
%X = 1
REPEAT 31 TIMES
%X = %X * 2
END REPEAT
PRINT %X
REPEAT FOREVER
REPEAT FOREVER
.
READ SCREEN CUSTOMERS
IF %SCREEN:PFKEY = +3 THEN
LOOP END
END IF
.
END REPEAT
Record Loops
Value Loops
BEGIN
EACH.COUNTY: FIND ALL VALUES OF COUNTY
EACH.CITY: FIND ALL VALUES OF CITY
EACH.STATE: FOR EACH VALUE OF STATE
FOR EACH VALUE IN EACH.COUNTY
FOR EACH VALUE IN EACH.CITY
PRINT COLOR AND MAKE AND MODEL
END FOR
END FOR
END
Ordering Output
Ordering Output
Four Methods in Decreasing Efficiency
Sorted File
ORDERED with In Order Clause
FOR EACH VALUE in Order Clause
SORT Statement
SORTKEY = LASTNAME
BEGIN
FD: IN CLIENTS FD
CITY = PALM HARBOR
END FIND
FOR EACH RECORD IN ORDER
PRINT NAME AND ADDRESS
END FOR
END
Note: Ordering field must be file SORTKEY
Sort Statement
Sort Statement
BEGIN
FD: IN VEHICLES FD MAKE = FORD
END FIND
ST: SORT RECORDS IN FD BY MODEL
FOR EACH RECORD IN ST
PRINT MAKE AND MODEL
END FOR
END
Note: Field must be visible
Lists
PLACE Statement
PLACE RECORDS IN FD.FORDS ON LIST FORDS
PLACE RECORDS IN FD.CAL ON LIST CALIFORNIA
PLACE RECORDS ON LIST FORDS ON LIST CARS
PLACE RECORD ON LIST CARS
File Maintenance
Update Types
1. Add a new record
2. Delete an existing record
3. Add a new fieldname = Value to a record
4. Delete an existing Fieldname = Value
5. Change the value of an existing Fieldname
= Value
Note: File must be opened with update privileges
for updates to be allowed.
Output
1 GLEN
2 CATHY
3 CHRIS
Note: Occurrences are processed in the order
4 JOHN
in which they occur in the record.
5 BILL
Counting Occurrences
BEGIN
FD: IN CLIENTS FD
END FIND
FR FD
CT: COUNT OCCURENCES OF CHILD
PRINT CHILD (COUNT IN CT)
END FOR
END
Image Declaration
IMAGE CLIENT
NAME
SPOUSE
CHILD1
CHILD2
CHILD3
SSN
DIVISION
END IMAGE
IS
IS
IS
IS
IS
IS
IS STRING LEN 20
STRING LEN 20
STRING LEN 20
STRING LEN 20
STRING LEN 20
STRING LEN 9
STRING LEN 7
Redefine Image
IMAGE POLICYHOLDER
P_RECTYPE
IS STRING LEN 1
P_ NAME IS STRING LEN 20
P_ POLICY.NO
IS STRING LEN 5
CITY
IS STRING LEN 30
IMAGE DRIVER
D_ RECTYPE
IS STRING LEN 1
D_ NAME IS STRING LEN 20
D_ POLICY.NO IS STRING LEN 5
DRIVER.ID
IS STRING LEN 10
VIN IS STRING LEN 20
END IMAGE
Redefine Image
IMAGE POLICYHOLDER
P_RECTYPE
IS
P_ NAME
IS
P_ POLICY.NO
IS
CITY
IS
IMAGE DRIVER AT P_
D_ POLICY.NO
DRIVER.ID
VIN
END IMAGE
STRING
STRING
STRING
STRING
LEN
LEN
LEN
LEN
1
20
10
30
POLICY.NO
IS STRING LEN 5
IS STRING LEN 10
IS STRING LEN 25
String
Binary
Packed
Zoned Decimal
Float
Exponential Format
Note: Conversions are done
automatically
when values are read into the image.
.
.
Terminal Operations
Editor Commands
Line Commands
I
D
C
P
F
R
U
User Resetable
LGTBL (Utable)
HDRCTL (Reset)
Non-Resetable
NORQS
CURFILE
VERSION
Section 4
Summary
Temporary Procedures
Permanent Procedures
Temporary Procedures
Permanent Procedures
CALL Statement
BEGIN
CALL CALCULATE
.
.
.
CALCULATE: SUBROUTINE
.
.
END SUBROUTINE
END
RETURN Statement
BEGIN
CALCULATE: SUBROUTINE
.
.
END SUBROUTINE
END
Simple Subroutines
CALC: SUBROUTINE
%AVERAGE.SALES = %MONTH.SALES / %DAYS
PRINT 'AVERAGE SALES -' AND %AVERAGE
END SUBROUTINE
The variables that are used in the subroutine are
shared with the main body of the program. Simple
subroutines are easier to code but care must be
taken to avoid modifying the value of variables that
may be used elsewhere in the request. Simple
subroutines are not easily transported.
Complex Subroutines
BEGIN
%MSALES
IS FIXED DP 2
%NUM.DAYS IS FIXED
...
ON Units
ON ATTENTION Unit
In a Full Screen Environment this specifies
the action to take if the user presses the
<BREAK>, <ATTN>, <PAL1>, or enters
*CANCEL
ON ATTENTION
PRINT 'You have pressed the Attn Key'
STOP
END ON
$READ
Note: Makes code generic
BEGIN
%NAME = $READ('PLEASE ENTER YOUR NAME')
PRINT 'SEARCHING FOR' AND %NAME
FD: IN CLIENTS FD
NAME = %NAME
END FIND
FR FD
PRINT NAME AND CITY
END FOR
END
Date $Functions
$Date
PRINT $DATE
$Datechk
------> 96-09-12
$Datecnv
String Manipulation
$Functions
$Index
%A = $INDEX('WASHINGTON GEORGE', )
PRINT %A -----> 11
$SUBSTR
$LEN
%LENGTH = $LEN(%FIRST)
PRINT %LENGTH -----> 6
Section 6
Summary
Action Keys
Screen Declaration
Screen
Manipulation
Screen Usage
Personnel Entry
Name: _________________ SSN: _____________
Address: _____________________________________
City: __________ State:___
Division: _____________
PF1/Help PF3/Quit
PF12/Exit
Action Keys
User Language screens are IBM 3270 full
screen reads.
<PFKeys>
<Attn>
<PA1>
Screen Declarations
BEGIN
SCREEN CLIENTS
TITLE 'Personnel Entry'
SKIP 1 LINE
PROMPT 'Name:' AT 5 BRIGHT INPUT NAME LEN 20 PAD WITH _ REQUIRED PROMPT 'SSN:' AT 45 INPUT SSN LEN 9 REQUIRED
SKIP 1 LINE
PROMPT 'Address:' AT 5 INPUT ADDRESS LEN 60 PAD WITH _
SKIP 1 LINE
PROMPT 'City:' AT 5 .
PROMPT PF1 AT 5 LEN 9 DEFAULT 'PF1/HELP'
END SCREEN
END
Default Statements
DEFAULT INPUT PAD '_'
DEFAULT PROMPT GREEN
BEGIN
SCREEN CLIENTS
DEFAULT INPUT PAD '_'
.
END SCREEN
END
Screen Manipulation
Statements
Read
Displays screen for user input
(constitutes a terminal I/O point)
Modify
item
PFKey Handling
BEGIN
SCREEN CLIENTS
TITLE 'Personnel Entry'
.
PROMPT 'PF1/HELP'
END SCREEN
READ SCREEN CLIENTS
IF %CLIENTS:PFKEY EQ + 1 THEN
CALL HELP
END IF
.
.
END
Section 7
Model 204 Application Subsystem
Facility
APSY
Apsy Features
Precompilation of procedures
Subsystem Definition
Operational Parameters
Screen
SUBSYSMGMT
Operational Parameters
Browse Mode
Subsystem Name: MERCURYT
Enter Status: 2 ( 1. PUBLIC
2. SEMI-PUBLIC
3. PRIVATE )
Autostart:
N
Lock File/Groups:
N
Log user into M204:
N
Log user out of M204: N
Auto Commit:
N
Maximum Iterations: 10
Message Display Options
Disconnect:
Y
Informational: Y
Error: Y
1 = HELp 2 = FILeuse
3 = QUIt
7=
8=
9 = USErdef
4=
10 =
5=
11 = PROcedure
6 = SYSclass
12 = END
1 = HELp
7 = BACKward
12 = END
2=
8 = FORward
Deferred
Ordered-index
Deferred Name
3 = QUIt
4 = OPEration
9 = USErdef 10 =
5 = PROcedure
6=
11 = SYSclass
2 = FILeuse
3 = QUIt
4 =OPEration
5 =PROcedure
6=
12 = END
User Definitions
BROWSE MODE
1 = HELp
SYSCLASS
7 = BACkward
2 = FILeuse
3 = QUIt
8 = FORward 9 =
4 =OPEration
10 =
5 =PROcedure
11 =
6=
12 = END
2=
8 = FORward
3 = QUIt
4 =DELusers
5 =PREview
6=
9=
10 =COPyusers 11 =CPReplace 12 = END
The End