190 likes | 345 Views
Embedded SQL. Journalling. Journal. Controlling object used to record changes to database objects. Journal Entry. Record of change to a database object. Journal Receiver. Holds the Journal Entry. A Journal can have more than one journal receiver. Journal. *FILE. *FILE. Journal
E N D
Journal • Controlling object used to record changes to database objects
Journal Entry • Record of change to a database object
Journal Receiver • Holds the Journal Entry. • A Journal can have more than one journal receiver.
Journal *FILE *FILE Journal Receiver Journal Receiver Journal Entries Journal Entries Journal Entries Journal Entries
Creating a Collection with a Data Dictionary • Automatically creates a journal to log changes to the database files created in the collection
Creating a Journal Receiver CRTJRNRCV • Fill in the Journal Receiver name, the library where it will be stored
Creating a Journal CRTJRN • Fill in the name of the journal and the library that it is stored in. • Attach the journal receivers by listing them in the Journal Receiver Fields
Start Journal Physical File STRJRNPF • Used to attach physical files to the Journal Receivers. • Record images parameter defines whether the before/after image of the file will be stored or just the after.
Using the Journal Commitment Control
Commit • Used to finalize the database change. • Happens automatically when a program is ended normally.
Rollback • Uses the journal entries to take the database back to the state that it was in after the last commit.
Displaying a Journal • DSPJRN
Working Storage • Include SQLCA • SQLSTATE (PIC XXXXX)
SQL Equivalents Read a record? Delete a record? Add a record? Change a record?
Retrieving more than one record • Declare a cursor • Contains a select statement that retrieves all of the records • Open the cursor • Loads the data into the cursor • Fetch • Fetches a record from the cursor (default is next) • Close the cursor • Clears the data in the cursor