Download presentation
Presentation is loading. Please wait.
Published byBeverley Chase Modified over 9 years ago
1
Agenda Journalling More Embedded SQL
2
Journalling
3
Journal Controlling object used to record changes to database objects
4
Journal Entry Record of change to a database object
5
Journal Receiver Holds the Journal Entry. A Journal can have more than one journal receiver.
6
Journal Receiver Journal Receiver Journal Entries Journal Entries Journal Entries Journal Entries *FILE
7
Creating a Collection with a Data Dictionary Automatically creates a journal to log changes to the database files created in the collection
8
Setting up the Journal
9
Creating a Journal Receiver CRTJRNRCV Fill in the Journal Receiver name, the library where it will be stored
10
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
11
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.
12
Using the Journal Commitment Control
13
Commit Used to finalize the database change. Happens automatically when a program is ended normally.
14
Rollback Uses the journal entries to take the database back to the state that it was in after the last commit.
15
More Embedded SQL
16
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
17
Steps to create a dynamic SQL Statement Build the character string containing your SQL code Use the prepare statement to create the dynamic SQL statement Eg. Prepare x from :SqlString Creates the dynamic sql statement called x. SqlString contains an SQL statement Use the execute statement
18
Statements that can be executed dynamically Alter Table Call Comment On Commit Create Alias Create Collection Create Distinct Type Create Function Create Index Create Procedure Create Table Create View Delete Drop Free Locator Grant Insert Label On Lock Table Rename Revoke Rollback Set Path Set Transaction Update
19
TESTCOLL
20
What do we use when we want to retrieve more than one record at a time? CURSORS!!
21
Why cursors? SELECT INTO can only retrieve 1 record at a time
22
What is a Cursor? A table created at run time to hold data
23
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
24
Patsearch
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.