Upload
beverley-chase
View
241
Download
2
Tags:
Embed Size (px)
Citation preview
Journal
JournalReceiver
JournalReceiver
Journal Entries
JournalEntries
JournalEntries
JournalEntries
*FILE*FILE
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.
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.
Dynamic SQL
• Used to build SQL statements as strings and then execute the string
• Remember Lab 2 – we had to hard code the library to delete instead of using a parameter?– Solution to the problem is Dynamic SQL
Steps to create a dynamic SQL Statement
• Build the character string containing your SQL code
• Use the prepare statement to create the dynamic SQL statementEg. Prepare x from :SqlString
Creates the dynamic sql statement called x. SqlString contains an SQL statement
• Use the execute statement
Statements that can be executed dynamically
Alter TableCallComment OnCommitCreate AliasCreate CollectionCreate Distinct TypeCreate FunctionCreate IndexCreate ProcedureCreate TableCreate ViewDelete
DropFree LocatorGrantInsertLabel OnLock TableRenameRevokeRollbackSet PathSet TransactionUpdate
Steps to using cursors
• Declare the cursor– Defines what the cursor will look like
• Open the cursor– Loads the cursor with data
• Fetch (ie read) rows from the cursor– Reads a record from the cursor
• (optionally) update or delete the most recently fetched row
• Close the cursor– If applicable, writes changes to the database– Clears the cursor