In this quick tutorial you will learn How To Database Updates in Pega 8.
- Most Pega applications need to exchange data with each other as well as with external systems.
- It contains all of the rules and system information for a Pega application.
- Designers can create and update rules and system settings without updating the database structure.
- Detailed knowledge about the database is unnecessary for most application tasks.
- Pega application information such as cases, assignments, and case history is stored in PegaDATA.
- As users interact with a Pega system, rows of the database are automatically created, updated, saved, and deleted.
- Pega separates this data into a separate database from rules and system data to support high availability and in-place upgrades.
- Pega applications almost always require access to data stored outside of the application.
- To directly manage the data read from and written to an external database, you can create an external class in your application.
- An external class cannot belong to a class group.
- It corresponds to a database table not administered by Pega.
- Each external class should be mapped to a unique database table.
- An external class does not contain either the pzInsKey or pxObjClass properties.
- These properties are used by Pega as key columns to identify rows in tables in the PegaRULES and PegaDATA databases.
- The external class uses the key column specified by the database table to identify unique rows instead.
- An external class maps Pega properties to database columns.
- As a best practices pega suggest the use of data pages to both read and save data back to the system of record for easy configuration and maintainability.
- By configuring a savable data page, you can read and write updated information without the use of an activity.
Reading and Writing to a Database:
- When advanced processing to a database table cannot be achieved with savable data pages.
- You can read from, and write to the database with Obj-methods using activities.
- Obj-methods are a subset of activity methods used to operate on one or more objects, or rows, in a database table.
Read from a database:
- Obj-Open or Obj-Open-By-Handle loads an instance of a class stored in either the PegaRULES database or an External database.
- Both methods create a clipboard page for the open instance.
- Obj-Browse searches the database, retrieves multiple records, and copies them to the clipboard as an array of embedded pages.
- Obj-Refresh-and-Lock tests whether a clipboard page is current and if a lock is held.
- If the object is not locked, the activity acquires a lock and refreshes the page if it is stale.
Save to a database:
- Obj-Save saves the contents of a clipboard page to the database.
- It immediately writes the object to the database only if the WriteNow parameter is selected.
- If the WriteNow parameter is not selected, the Obj-Save operation becomes a deferred save.
- A deferred save adds a deferred operation to an internal list of operations to be performed on the next commit.
- A valid reason to perform a WriteNow is the need to immediately reread the instance before issuing a commit.
Delete a database record:
- Use Obj-Delete or Obj-Delete-By-Handle to remove an instance from the database.
- Obj-Delete to delete a database row identified by a page on the clipboard.
- Obj-Delete-By-Handle to delete an instance using its unique ID without requiring a page on the clipboard.
- Obj-Save-Cancel: cancels the most recent uncommitted Obj-Save method so that the instance is not written as part of a later Commit operation.
- Rollback method: cancels or withdraws any previous uncommitted changes to the PegaRULES database (and to external databases accessed from an external class) from the current thread.
SQL Connect rules:
- The Connect SQL rule provides four tabs to enter SQL statements that execute during performance – Open, Delete, Save, Browse.
- Use a Connect SQL rule To execute a SQL command or stored procedure
- Invoke Connect SQL rules from an activity using RDB methods.
Hope you learned How To Database Updates in Pega 8.