DB2400_ver_2
-
Upload
anonymous-7r2olofv -
Category
Documents
-
view
216 -
download
0
Transcript of DB2400_ver_2
-
7/29/2019 DB2400_ver_2
1/60
1DB2/400 ver 2.0
DB2/400
Version 2.0
Release Date: 25/06/2010
HCL Technologies Ltd.
-
7/29/2019 DB2400_ver_2
2/60
Database Management Systems
A system whose overall purpose is to record andmaintain information
A database is a repository for stored data and
programs to manipulate it.
Data Models-
A data modelis a collection of concepts for describing
data
A Schema is a description of a particular collection of
data using the given data model
The relational model is the most widely used model
today
2
-
7/29/2019 DB2400_ver_2
3/60
Levels of Abstraction
Many Viewsand singleConceptual and Physical
Schema
Views Describe how users see
the data Conceptual Schema defines
the logical structure
(Fields)and relation between
them. Physical Schema defines the
physical files and Indexes
3
-
7/29/2019 DB2400_ver_2
4/60
Relational DBMS
Based on Relational Mathematics principles Data is represented in terms of rows and columns of a table
Addresses all types of relations
Easy to design
No anomalies for insert/delete/update
Relational Terminology
Tuple (Row)
Attribute (Column)
Relation (Table)
4
-
7/29/2019 DB2400_ver_2
5/60
Integrity Constraints
A unique key can uniquely identify each row in atable
A primary key is a combination of columns which
uniquely specify a row. It is a special case of
unique keys.
One difference is that primary keys have an
implicit NOT NULL constraint while unique keys
do not.
5
-
7/29/2019 DB2400_ver_2
6/60
The foreign key identifies a column or set of columns in one
(referencing) table that refers to a column or set of columns in another
(referenced) table. The columns in the referencing table must referencethe columns of the primary key or other superkey in the referenced
table.
Integrity Rules -
Entity Integrity-Primary key cannot have null value.
Referential Integrity-Foreign key should be the primary key in the
referenced table.
6
-
7/29/2019 DB2400_ver_2
7/60
Normalization
Normalization - process of removing data
redundancy by decomposing relations in a
Database.
The decomposition approach starts with onerelation and the relation is decomposed intomore number of relations to remove insert,delete and update anomalies.
1NF, 2NF, 3NF and BCNF can be achievedby this approach.
7
-
7/29/2019 DB2400_ver_2
8/60
Un normalized
ClientNo cName propertyNo pAddress rentStart rentFinish rent ownerNo oName
CR76John
kay
PG4
PG16
6 lawrence
St,Glasgow
5 Novar Dr,
Glasgow
1-Jul-00
1-Sep-02
31-Aug-01
1-Sep-02
350
450
CO40
CO93
Tina
Murphy
Tony
Shaw
CR56Aline
Stewart
PG4
PG36
PG16
6 lawrence
St,Glasgow
2 Manor Rd,
Glasgow
5 Novar Dr,
Glasgow
1-Sep-99
10-Oct-00
1-Nov-02
10-Jun-00
1-Dec-01
1-Aug-03
350
370
450
CO40
CO93
CO93
Tina
Murphy
Tony
Shaw
Tony
Shaw
-
7/29/2019 DB2400_ver_2
9/60
First Normal Form
First Normal Form is a relation in which the intersection of each There are two approaches to removing repeating groups from
unnormalized tables:
Removes the repeating groups by entering appropriatedata in the empty columns of rows containing the
repeating data.
Removes the repeating group by placing the repeating
data, along with a copy of the original key attribute(s), in aseparate relation. A primary key is identified for the new
relation.
-
7/29/2019 DB2400_ver_2
10/60
First Normal Table(1st Approach)
ClientNo propertyNo cName pAddress rentStart rentFinish rent ownerNo oName
CR76 PG4John
Kay
6 lawrence
St,Glasgow1-Jul-00 31-Aug-01 350 CO40
Tina
Murphy
CR76 PG16John
Kay
5 Novar Dr,
Glasgow1-Sep-02 1-Sep-02 450 CO93
Tony
Shaw
CR56 PG4Aline
Stewart
6 lawrence
St,Glasgow1-Sep-99 10-Jun-00 350 CO40
Tina
Murphy
CR56 PG36Aline
Stewart
2 Manor Rd,
Glasgow10-Oct-00 1-Dec-01 370 CO93
Tony
Shaw
CR56 PG16Aline
Stewart
5 Novar Dr,
Glasgow1-Nov-02 1-Aug-03 450 CO93
Tony
Shaw
-
7/29/2019 DB2400_ver_2
11/60
1NF with the second approach
ClientNo cName
CR76 John Kay
CR56 Aline Stewart
ClientNo propertyNo pAddress rentStart rentFinish rent ownerNo oName
CR76 PG46 lawrence
St,Glasgow1-Jul-00 31-Aug-01 350 CO40
Tina
Murphy
CR76 PG165 Novar Dr,
Glasgow1-Sep-02 1-Sep-02 450 CO93
Tony
Shaw
CR56 PG46 lawrence
St,Glasgow1-Sep-99 10-Jun-00 350 CO40
Tina
Murphy
CR56 PG362 Manor Rd,
Glasgow10-Oct-00 1-Dec-01 370 CO93
Tony
Shaw
CR56 PG165 Novar Dr,
Glasgow1-Nov-02 1-Aug-03 450 CO93
Tony
Shaw
-
7/29/2019 DB2400_ver_2
12/60
Full functional dependency
Full functional dependency indicates that if A and B are
attributes of a relation, B is fully functionally dependent on
A if B is functionally dependent on A, but not on any proper
subset of A.
A functional dependency AB is partially dependent if there
is some attributes that can be removed from A and the
dependency still holds.
-
7/29/2019 DB2400_ver_2
13/60
Second Normal Form (2NF)
Second normal form (2NF)is a relation that is in first
normal form and every non-primary-key attribute is fully
functionally dependent on the primary key.
The normalization of 1NF relations to 2NF involves the
removal of partial dependencies. If a partial dependency
exists, we remove the function dependent attributes from
the relation by placing them in a new relation along witha copy of their determinant.
-
7/29/2019 DB2400_ver_2
14/60
2NF ClientRental relation
ClientNo cName
CR76 John Kay
CR56 Aline Stewart
Client
ClientNo propertyNo rentStart rentFinish
CR76 PG4 1-Jul-00 31-Aug-01
CR76 PG16 1-Sep-02 1-Sep-02
CR56 PG4 1-Sep-99 10-Jun-00
CR56 PG36 10-Oct-00 1-Dec-01
CR56 PG16 1-Nov-02 1-Aug-03
Rental
propertyNo pAddress rent ownerNo oNamePG4 6 lawrence St,Glasgow 350 CO40 Tina Murphy
PG16 5 Novar Dr, Glasgow 450 CO93 Tony Shaw
PG36 2 Manor Rd, Glasgow 370 CO93 Tony Shaw
PropertyOwner
-
7/29/2019 DB2400_ver_2
15/60
Third Normal Form (3NF)
Transitive dependency
A condition where A, B, and C are attributes of a relation such that
if AB and B C, then C is transitively dependent on A via B
(provided that A is not functionally dependent on B or C).Third normal form (3NF)
A relation that is in first and second normal form, and in which
no non-primary-key attribute is transitively dependent on the
primary key.
The normalization of 2NF relations to 3NF involves the removal
of transitive dependencies by placing the attribute(s) in a new
relation along with a copy of the determinant.
-
7/29/2019 DB2400_ver_2
16/60
ClientNo cName
CR76 John Kay
CR56 Aline Stewart
Client
ClientNo propertyNo rentStart rentFinish
CR76 PG4 1-Jul-00 31-Aug-01
CR76 PG16 1-Sep-02 1-Sep-02
CR56 PG4 1-Sep-99 10-Jun-00
CR56 PG36 10-Oct-00 1-Dec-01
CR56 PG16 1-Nov-02 1-Aug-03
Rental
propertyNo pAddress rent ownerNo
PG4 6 lawrence St,Glasgow 350 CO40
PG16 5 Novar Dr, Glasgow 450 CO93
PG36 2 Manor Rd, Glasgow 370 CO93
PropertyOwner
3NF ClientRental relation
ownerNo oName
CO40 Tina Murphy
CO93 Tony Shaw
Owner
-
7/29/2019 DB2400_ver_2
17/60
System Concepts
Object Oriented Technology :- Everything on AS/400 that can be stored or retrieved is contained in
an Object.
A user is not concerned with the space his object occupies. The
system allocates space automatically.
The Licensed Internal Code that sits above the hardware with an
Object Based Kernel. The Kernel has been written in C++ and is
fully Object Oriented giving all the advantages of flexibility, code
reuse, programming efficiency, and error reduction that come from
Object Oriented Programming.
17
-
7/29/2019 DB2400_ver_2
18/60
Single Level Storage :-
The AS/400 system is a shared system in which all portions ofmain and auxiliary storage are addressed as though they are
within a single area (or level).
The system uses the object name to determine where the object
exists in the system.
operations cannot be performed on an object that is not in main
storage, the system moves a part or all of the object into main
storage as it is needed and moves it back into auxiliary storage
when it is not needed. This transfer is controlled by the system
and does not require control by the user or programmer
18
AS/400 Obj t
-
7/29/2019 DB2400_ver_2
19/60
AS/400 Objects:
Libraries:A library is an object that is used to group relatedobjects and to find objects by name. Two different objects withthe same can exist in the same library, only if their objects types
differ. However, two objects with the same name and type can
exist in different libraries.
There are three types of libraries :
Systems
User
Product
Folders:A folder is a named object that is used as a directory
for documents and other folders.
Files:File is an object that contains either a set of relatedrecords
19
AS/400 Obj t
-
7/29/2019 DB2400_ver_2
20/60
AS/400 Objects:
Programs:A program is an object containing a set ofinstructions that tell the system where to get information, how toprocess it and where to put the results.
Job Queue: The jobq manages the batch request submittedby the users.
Out Queue:As the job processes a request to print data itgets data from a database file and uses the print device file to
format the data.
Message Queue: Communication between programsbetween jobs, between users, between users and programs and
between users and the system occurs through messages.
Data Queue: Programs can set up data queues to be usedby the entire application so that all programs can refer to a
single set of data and variables passed to the programs through
the queue.20
AS/400 Obj t
-
7/29/2019 DB2400_ver_2
21/60
AS/400 Objects:
User Profiles:A user profile is an object that identifies aparticular user or a group of user to the AS/400 system. Theuser is known in the system by user profile name.
Menu:The menu allows users to select the task they wouldlike to perform without having to use the system commands.
Subsystem:A subsystem is a single, predefined operatingenvironment through which the system coordinates the work
flow and resource use.
21
-
7/29/2019 DB2400_ver_2
22/60
22DB2/400 ver 1.0
DB2/400
Database Files are files that contain data or provide access to data.
Physical files Type(*FILE) Attribute (PF)
Logical Files Type(*FILE) Attribute(LF)
PF can have only one record format.
Field Reference files are files that contain no data but
contain only descriptions of the fields.
Source Physical files are also database files.
-
7/29/2019 DB2400_ver_2
23/60
23DB2/400 ver 1.0
Physical File
A physical file is composed of four important
parts, Object Header : That contains regular object information
Record Format : Describes the format in which information is
stored.
Access path : Describes the order in which the records are
retrieved.
Data Members - Contains Data
-
7/29/2019 DB2400_ver_2
24/60
24DB2/400 ver 1.0
Physical Files
Data Members
Physical File
Member 1 Member 2 Member 3
The PF s and Source Physical files are the only two files which containdata and are the only files that contain members.
-
7/29/2019 DB2400_ver_2
25/60
25DB2/400 ver 1.0
Physical Files
DDS describes structure the physical file.
File -- blank name type; optional; when used, must precede record type
Record -- R name type; one required for physical file
Field -- blank name type; describes fields; follows record; almostalways present
Key -- K name type; optional; follows field entries
File and field Naming convention
File Name Max of 10 Characters
Record Format Max of 10 Characters Field Names should be unique.
A * in the 7th column of the DDS represents that as a comment
line.
-
7/29/2019 DB2400_ver_2
26/60
Field-Level Entries After you insert a record-format line, you can enterfield-level specifications. For these,
you leave the Name Type field blank. But you must enter values for:
Name (field name)
Length (number of characters or digits)
Data Type (e.g., character, zoned decimal, packed decimal, binary, date, time)
For numeric fields, you must also enter the number of decimal positions. Name. For record and field names, use from one to 10 characters, Embedded blanks are
not allowed in a name. Within a record format, field names must be unique.
Length. Length is the number of characters or digits in the field.
For numeric data types, the length specification really means the number ofdigits in the
field.
For date, time, and timestamp types, you do not specify a value for length; it is
determined by type, and for date fields, by format. The values shown (in the previous
slide) for date, time, and timestamp data types are the number of characters needed to
display the stored values, not the number of bytes required for disk storage.
26DB2/400 ver 1.0
-
7/29/2019 DB2400_ver_2
27/60
Field-Level Entries
Data Types
Abbreviation Data type
P Packed decimal
S Zoned decimal
B Binary
F Floating-point (short)
F Floating-point (long)
A Character
H Hexadecimal
L Date
T Time
Z Timestamp
27DB2/400 ver 1.0
For zoned decimal(length 9), then thetrue length of the field is 9 (bytes and
digits). But if the same field is typed P
forpacked decimal, then the value 9
specified for length really means nine
digits, and the true field length is five
bytes. (Length in bytes of a packed-
decimal field can be calculated as (Total
digits / 2) + 1, throwing away any
decimal part.)
This difference in length is due to the
way in which numeric data is stored inpacked-decimal format: two digits per
byte
except for the rightmost
-
7/29/2019 DB2400_ver_2
28/60
Field-Level Entries
Advantages of storing numeric data in packed-decimal format: The field itself is smaller (requiring fewer bytes of storage space)
Arithmetic and logic operations are more efficient (requiringfewer intermediate conversion steps)
Minor disadvantages to storing numbers as packed decimal:
A zoned-decimal numeric field of a physical file can be redefinedas a character field through a logical file
NOTE: If you dont explicitly provide a data type, the default is A (alphanumeric/
character) when no decimal-positions value is specified. If you provide a decimal-
positions value and do not specify a data type, DDS defaults to the numeric packed-
decimal (P) data type.
28DB2/400 ver 1.0
-
7/29/2019 DB2400_ver_2
29/60
Field-Level Entries
29DB2/400 ver 1.0
If you do not use keyword
DATFMT, the default is
*ISO
format whose display
format isyyyy-mm-dd
(10 characters).
Timestamp data includes
both the date and the time
and is formatted asyyyy-
mm-dd-hh.mm.ss.uuuuuu
(26 characters), whereuuuuuu represents
millionths of a second
-
7/29/2019 DB2400_ver_2
30/60
30
Example
-
7/29/2019 DB2400_ver_2
31/60
Keywords
31
-
7/29/2019 DB2400_ver_2
32/60
Keywords
32
-
7/29/2019 DB2400_ver_2
33/60
33DB2/400 ver 1.0
Physical Files
File Level Keywords Unique, LIFO,FIFO,FCFO,REF
Record Level Keywords TEXT
Field Level Keywords CMP,COLHDG,DATFMT,DATSEP,DFT,REFFLD,TEXT,TIM
SEP,VALUES , range
Key Field -Level Keywords DESCEND,ABSVAL
-
7/29/2019 DB2400_ver_2
34/60
34DB2/400 ver 1.0
-
7/29/2019 DB2400_ver_2
35/60
Physical Files Members
ADDPFM) command adds a named member to a physical file,which must already exist on the system.
The maximum number of members that can be added to the file is
specified for the Maximum members (MAXMBRS) parameter
on the Create Physical File (CRTPF) command or the Change
Physical File (CHGPF) command.
Each member added has the same attributes as those defined in
the physical file, its own set of data records, and its own access
path, as specified in the data description specifications (DDS).
35DB2/400 ver 1.0
-
7/29/2019 DB2400_ver_2
36/60
36DB2/400 ver 1.0
Physical Files
Common commands On physical Files RUNQRY *N CUSTOMER
DSPPFM CUSTOMER
WITHIN STRSQL - SELECT * FROM CUSTOMER
DLTF CUSTOMER
DSPFFD CUSTOMER DSPFD CUSTOMER
CLRPFM CUSTOMER - Clears the physical File.
CHGPFM
DSPDBR
-
7/29/2019 DB2400_ver_2
37/60
37DB2/400 ver 1.0
Physical Files ConstraintsAdding a Unique Constraint
ADDPFCST FILE(MYLIB/LOCATIONS) TYPE(*UNQCST) KEY(REGION)CST(Personnel_by_REGION)
This command adds a unique constraint to the LOCATIONS file in the MYLIB library.
The field that defines the access path is REGION. The name of the access path is
Personnel_by_REGION.
Adding a Referential Constraint ADDPFCST FILE(ADMN/PERSONNEL) TYPE(*REFCST) KEY(REGION)
CST(1994Hires) PRNFILE(MYLIB/LOCATIONS) PRNKEY(REGION)
DLTRULE(*CASCADE) UPDRULE(*RESTRICT)
This command adds a referential constraint to the PERSONNEL file in the ADMN
library. The field that defines the access path is REGION, which is also the key for the
parent file LOCATIONS in the MYLIB library. The name of the access path is1994Hires. According to the delete rule of cascade, if a record in the LOCATIONS file
is subsequently deleted, and that record matches a record in the PERSONNEL file, the
record also will be deleted from the PERSONNEL file. According to the update rule of
restrict, subsequent changes to the LOCATION file records defined in the constraint are
restricted at the beginning of the update request.
-
7/29/2019 DB2400_ver_2
38/60
Adding a Check Constraint
ADDPFCST FILE(PERSONNEL/SALARY) TYPE(*CHKCST)
CST(Upper_Salary_Limit) CHKCST('EMPSAL
-
7/29/2019 DB2400_ver_2
39/60
Data dictionary
A Data dictionary is to setup a file with all the data fields used inthe application, but with no data.
whenever the field is needed the DDS for the file points back to
this "dictionary" file (using REF or REFFLD).
39DB2/400 ver 1.0
-
7/29/2019 DB2400_ver_2
40/60
40DB2/400 ver 1.0
Logical Files
A Logical File is the logical view of a Physical file. Itprovides a access path to the physical File.
Non Join Logical Files
A Non- Join logical file can be either a simple logical file which contains
only one record format or multi record format.
Join Logical Files
Joins 2 - 32 physical files.
-
7/29/2019 DB2400_ver_2
41/60
41DB2/400 ver 1.0
Logical Files
Non Join logical file - Single Record format
Employee State
1000 AP
1001 UP
1002 MP
1003 HA
If file is keyed by state
Employee State
1000 AP
1003 HA1002 MP
1001 UP
Logical Files
-
7/29/2019 DB2400_ver_2
42/60
42DB2/400 ver 1.0
Logical Files
Non Join logical file - Accessing two files - Union on common keyEmployee State Employee Region
1000 AP 1000 HY
1001 UP 1000 VZ
1002 MP 1001 LC
1003 HA 1002 BOIf file is keyed by state
Employee State
1000 AP
1000 HY
1000 VZ
1001 UP
1001 LC
1002 MP
1002 BO
Logical Files
-
7/29/2019 DB2400_ver_2
43/60
43DB2/400 ver 1.0
Logical Files
Join logical file - Joining more than two files.Employee Dept Dept Dept Description
1000 AS AS AS/400
1001 UX UX Unix
1002 LN LN Lexis-Nexis
1003 CS CS Client ServerIf two files are joined by the field.
Employee Dept Description
1000 AS/400
1001 Unix
1002 Lexis-Nexis
1003 Client Server
Natural join, - Only matching from both files
Left outer join - All records from primary missing secondary defaults
Self join - Joining a file to itself.
-
7/29/2019 DB2400_ver_2
44/60
Logical File
44DB2/400 ver 1.044
-
7/29/2019 DB2400_ver_2
45/60
Multi format Logical File
45DB2/400 ver 1.045
Logical File Member
-
7/29/2019 DB2400_ver_2
46/60
46DB2/400 ver 1.0
Logical File Member
46DB2/400 ver 1.0
If the DTAMBRS parameter is specified on
the CRTLF or ADDLFM command as in
the following example:
DTAMBRS((PF1 M1) (PF2 (M1 M2))
(PF1 M1)
(PF2 (*NONE)) (PF3 M3))
Record format LOGRCD2 is associatedwith physical file member M1 in PF1 and
M1 and M2 in file PF2.
Record format LOGRCD3 is associated
with M1 in PF1 and M3 in PF3. No
members in PF2 are associated with
LOGRCD3.If the same physical file name is
specified on more than one PFILE
keyword, each occurrence of the physical
file name is handled as a different physical
file.
-
7/29/2019 DB2400_ver_2
47/60
47DB2/400 ver 1.0
Logical Files
Non Join Logical file File Level Keywords
REFACCPTH, DYNSLT,UNIQUE,FIFO...
Record Level Keywords
PFILE
Field Level Keywords
SST,CONCAT,RENAME
Key Field -Level Keywords
DESCEND,ABSVAL
Select Omit level keywords
-
7/29/2019 DB2400_ver_2
48/60
48DB2/400 ver 1.0
Logical Files
Join Logical file File Level Keywords
JDFTVAL
Record Level Keywords
JFILE,JOIN,JFLD
Field Level Keywords
JREF,
Key Field -Level Keywords
DESCEND,ABSVAL
Select Omit level keywords
-
7/29/2019 DB2400_ver_2
49/60
49DB2/400 ver 1.0
Logical File
Example of a self joinEMPNO EMPNAM MGRNO200 Srinivas 400
400 Sanjay 700
700 S Murali 800
EMPNO EMPNAM MGR Name
200 Srinivas Sanjay
400 Sanjay S Murali
-
7/29/2019 DB2400_ver_2
50/60
Join Logical File
50
C
-
7/29/2019 DB2400_ver_2
51/60
Commands CPYF
CPYF FROMFILE(PERSONNEL/PAYROLL) TOFILE(TESTPAY/PAYROLL) MB
ROPT(*ADD) CRTFILE(*YES) ERRLVL(10)
Because MBROPT(*ADD) is specified, the copied records are added to any existing records in the
to-file member. Because RCDFMT(*NONE) is assumed, the to-file TESTPAY/PAYROLL must
have the same record format as the from-file. If more than ten recoverable errors occur during the
copy operation, the operation ends.
CPYSRCF
CPYSRCF FROMFILE(QGPL/QCLSRC) TOFILE(MYLIB/CLSRC) FROMMBR(PGMA)
This command copies records from member PGMA of database source file QCLSRC which is in the
QGPL library.
CRTDUPOBJ
CRTDUPOBJ OBJ(FILEA) FROMLIB(LIB1) OBJTYPE(*FILE) TOLIB(LIB2) DATA(*YES)
The file named FILEA in library LIB1 is duplicated and stored in library LIB2. Authorities granted forFILEA are granted to the new FILEA in LIB2. The data records, constraints, and triggers
associated with FILEA in library LIB1 are copied to FILEA in LIB2.
WRKOBJ
DSPOBJD
51DB2/400 ver 1.0
Diff
-
7/29/2019 DB2400_ver_2
52/60
Difference
CPYF copy file member is to copy file content to an existing file.
If file does not exist then user can create a new file. The structure
will be based on source file.
CRTDUPOBJ create duplicate object, create clone exactly as the
source file with structure and content with its link to program and
logical file and its authority setting as well. no need to recompile
pgm that use this file
52DB2/400 ver 1.0
S Fil
-
7/29/2019 DB2400_ver_2
53/60
Save Files
A save file can be used with save and restore commands tocontain data that would otherwise be written to tape or diskette.A save file can also be used like a database file to read or write
records that contain save or restore information. A save file can
also be used to send objects to another user on network.
Create a save file
Save Object/ Libraries into the save file
Save onto tape or Ship via FTP
CRTSAVF SAVLIB,SAVOBJ
RSTLIB,RSTOBJ
DSPSAVF
53DB2/400 ver 1.0
DB2/400
-
7/29/2019 DB2400_ver_2
54/60
54DB2/400 ver 1.0
DB2/400
DFU
-
7/29/2019 DB2400_ver_2
55/60
55DB2/400 ver 1.0
DFU
Is a tool used to perform operations on
data physical files.
Can be used :Enter data,
Update files
File inquiries
STRDFU
T i
-
7/29/2019 DB2400_ver_2
56/60
Triggers A trigger defines an event that is to occur with a delete, insert,
update or read (any change) operation on a file.
The trigger program can be specified to be called before or after a
change operation occurs.
A maximum of 300 triggers can be added to one physical file.
Once a trigger is added to the physical file, all members of that
specified file are affected by the trigger.
Trigger program will run for each insert of the record. Say you
copied 100 records. Trigger program will be run for 100 times56DB2/400 ver 1.0
-
7/29/2019 DB2400_ver_2
57/60
Uses of triggers
Provide consistent auditing Prevent invalid transactions
Enforce complex business rules
Enforce complex security authorizations
Provide automatic event logging
Automatically generate derived column values Preserving data
consistency across different database tables
Commands-
ADDPFTRG
RMVPFTRG
57DB2/400 ver 1.0
WRKQRY
-
7/29/2019 DB2400_ver_2
58/60
WRKQRY The Work with Query (WRKQRY) command shows the
Work with Queries display. You can use this display tocreate, display, change, copy, delete, or print a query
definition, or to run a query.
IBM provided query language QUERY/400
This interface is easy to use but is different from PDM.
you can write a query without ever naming it. Of course,you must name it if you wish to save it.
Command-
WRKQRY58
DB2/400 ver 1.0
I t ti SQL
-
7/29/2019 DB2400_ver_2
59/60
59DB2/400 ver 1.0
Interactive SQL
The AS/400 also provides a SQL interface to thenative environment through a interactive SQL
interface.
STRSQL
-
7/29/2019 DB2400_ver_2
60/60
Journal ManagementA journal is an AS/400 objects used primarily to record changes to data in a
physical file member and optionally, changes to a logical files access path.
Records file opens, File closes, system IPLs, user generated entries andother types of Activity related to physical file.
When data is changed, a journal always puts after image entries into ajournal receiver. Optionally, you can specify that the journal should put bothbefore image and after images into the journal receiver.
Use Journal Management to recover critical data in AS/400 files.
Journal Management automatically creates a separate copy of file changesand, If necessary, uses the copy to recover data in file.
Commands-
CRTJRNRCV
CRTJRN