Oracle9i Application Developer's Guide - Workspace Manager
Release 1 (9.0.1)

Part Number A88806-01

Home

Book List

Contents

Index

Master Index

Feedback

Go to previous page Go to next page

1
Introduction

The need to manage complex, long-duration database transactions is common in today's engineering applications, AM/FM, geographic information systems (GIS), and computer-aided design (CAD) applications.

Conventional database management systems (DBMS) are designed to handle short-duration transactions, such as those in financial applications. However, these techniques are insufficient for engineering applications where a design can take days to complete and multiple users must access the same database. Traditional concurrency control techniques are well-defined and adequate for handling short-duration transactions. These techniques are highly robust for handling very large numbers of short, distinct transactions that are open for milliseconds or minutes. A conventional short transaction locks all records that are changed until the transaction is completed (either merged or rolled back). These concurrency control techniques, however, are insufficient for handling applications that must support long-duration transactions.

Database Workspace Manager, often referred to as Workspace Manager, provides a long-transaction framework built on a workspace management system. It uses a series of short transactions and multiple data versions to implement a complete long-transaction event that maintains atomicity and concurrency. Changes are stored in the database as different workspaces. Users are permitted to create new versions of data to update, while maintaining a copy of the old data. The ongoing results of the long transaction are stored persistently, assuring concurrency and consistency.

This chapter explains the terminology used and also describes the workings of this product. You must understand this background information to use Workspace Manager procedures. This chapter has the following main sections:

For a complete example of Workspace Manager, see Section 1.9. However, you may want to read the rest of this chapter first, to understand the concepts that the example illustrates.


Note:

Workspace Manager is installed by default in the Oracle seed database and any database created using the Database Configuration Assistant (DBCA). To use Workspace Manager in any other Oracle database, you must first perform the installation procedure described in Appendix A, "Installing Workspace Manager with Custom Databases"


1.1 Workspace Management

Workspace management refers to the ability of the database to hold different versions of the same record (that is, row) in one or more workspaces. Users of the database can then change these versions independently. There are two fundamental benefits of versioning in a database system:

The unit of versioning in the product is a database table. A table in the database can be version-enabled, which means that all rows in the table can now support multiple versions of data. The versioning infrastructure is not visible to the users of the database. After a table has been version-enabled, users automatically see the correct version of the record in which they are interested.

1.2 Workspace Concepts and Operations

A workspace is a virtual environment that one or more users can share to make changes to the data in the database. Workspace management involves managing one or more workspaces that can be shared by many users.

1.2.1 Hierarchy of Workspaces

There can be one or more versions of a row in a workspace from one or more version-enabled tables. The current or active version in a workspace refers to the version number in which the changes are currently being made. All changes made in a workspace are made by conventional short transactions. There can be a hierarchy of workspaces in the database. For example, a workspace can be a parent to one or more workspaces. By default, when a workspace is created, it is created from the topmost, or LIVE, database workspace. (Workspace names are case sensitive, and the workspace name of the live database is spelled LIVE. The length of a workspace name must not exceed 30 characters.) Users are included in workspaces by a GotoWorkspace operation.

Figure 1-1 shows a hierarchy of workspaces. Workspace 1 and Workspace 4 were formed off the LIVE database workspace; Workspace 2 and Workspace 3 were formed off Workspace 1, and Workspace 5 was formed off Workspace 4. After Workspace 1 was created, a user executed a GotoWorkspace operation specifying Workspace 1, and then executed CreateWorkspace operations to create Workspace 2 and Workspace 3. A comparable sequence was followed with Workspace 4 and Workspace 5.

Figure 1-1 Workspace Tree


Illustration of a workspace tree, with the LIVE workspace at the top.

1.2.2 Using Savepoints

A savepoint is a point in the workspace to which operations can be rolled back. It is analogous to a firewall, in that by creating a savepoint you can prevent any damage to the "other side" of the wall (that is, operations performed in the workspace before the savepoint was created).

Explicit savepoints can thus be created and later used to effect partial rollbacks in workspaces. In Figure 1-2, SP1, SP2, SP3 and SP4 are explicit savepoints that have been created in the workspaces indicated. (Savepoints are indicated by dashed lines in Figure 1-2.)

Figure 1-2 Savepoints


Illustration of savepoints (both explicit and implicit) in workspaces.

In addition, implicit savepoints are created automatically whenever a new workspace is created. Thus, in Figure 1-2 two implicit savepoints (SPa and SPd) are created in the LIVE workspace corresponding to Workspace 1 and Workspace 4 creation; two implicit savepoints (SPb and SPc) are created in Workspace 1 corresponding to Workspace 2 and Workspace 3 creation; and one implicit savepoint (SPe) is created in Workspace 4 corresponding to Workspace 5 creation. An implicit savepoint is needed so that the users in the child workspace get a view of the database that is frozen at the time of the workspace creation.

Workspace Manager uses the name LATEST to designate a logical savepoint that refers to the latest version in the workspace. LATEST is often the default when a savepoint is an optional parameter for a procedure.

1.2.3 Merging and Rolling Back Workspace Changes

Workspaces can be merged or rolled back.

Merging a workspace involves applying changes made in a workspace to its parent workspace, after which the workspace that had been merged ceases to exist (that is, it is removed). To merge a workspace, use the MergeWorkspace procedure.

Rolling back a workspace involves deleting either all changes made in the workspace or all changes made after a savepoint (that is, an explicit savepoint).

A workspace cannot be rolled back when it has open regular transactions. Rollback of a workspace leaves behind the workspace structure for future use; only the data in the workspace is deleted. (To completely remove a workspace, use the RemoveWorkspace procedure, as described in Section 1.2.7.)

1.2.4 Autocommitting of Workspace Manager Operations

Many Workspace Manager procedures by default commit the caller's current open regular transaction, if there is one. For example, if you compress a workspace or delete a savepoint, and if a regular transaction is open, that transaction is automatically committed when the requested Workspace Manager operation completes, unless you specify otherwise.

To override the automatic commit operation in such cases, you can specify the auto_commit parameter with a value of FALSE for many procedures. The auto_commit parameter has a default value of TRUE; however, if you specify a value of FALSE, any currently open regular transaction remains open, and no operations (including the Workspace Manager procedure) are committed until the transaction is committed.

Specifying FALSE for the auto_commit parameter is useful if you want to perform transactional operations unrelated to Workspace Manager before and after calling a Workspace Manager procedure, without having the Workspace Manager procedure terminate the transaction and make permanent the changes. If you later decide to roll back the transaction, all the operations (including the Workspace Manager procedure) are rolled back. Note that if you specify FALSE for the auto_commit parameter, you must remember to commit or roll back the transaction.

1.2.5 Resolving Conflicts

On a merge, the changes in the workspace are incorporated in its parent workspace. Rows that are changed in the child and parent workspace may lead to data conflicts. Conflicts are detected at merge time and presented to the user in conflict views. There is one conflict view per table, as described in Section 3.21. This view lists the primary key of the rows in conflict and also the column values of the rows in the two workspaces that form the conflict.

Conflicts have to be resolved manually by using the ResolveConflicts procedure. When there are no conflicts between the parent and child workspaces, the data in the two workspaces can be merged. Conflicts must be resolved before a MergeWorkspace or RefreshWorkspace operation can be performed.

Typically, you discover that conflicts exist when you attempt to merge or refresh a workspace and encounter an exception that refers to conflicts. The general process for resolving conflicts is as follows:

  1. Examine the xxx_CONF views (described in Section 3.21) to see what conflicts exist.

  2. Execute the BeginResolve procedure.

  3. Execute the ResolveConflicts procedure as often as needed: once per affected combination of table and workspace. After each successful execution of ResolveConflicts, perform a standard database commit operation and execute the MergeWorkspace procedure. (However, any changes are not made permanent in the database until you execute CommitResolve, as described in the next step.)

  4. After resolving all conflicts, execute one of the following procedures:

1.2.6 Freezing and Unfreezing Workspaces

A workspace can be frozen or not frozen. If a workspace is frozen, no changes can be made to data in version-enabled rows, and access to the workspace is restricted.

To make a workspace frozen, use the FreezeWorkspace procedure. To make a frozen workspace not frozen, use the UnfreezeWorkspace procedure.

In addition, some procedures automatically freeze one or more workspaces. Table 1-1 lists these procedures, the workspaces affected, and the mode in which the workspaces are frozen. (For explanations of the mode values, see the FreezeWorkspace procedure description in Chapter 2.)

Table 1-1 Freeze Results of Procedures  
Procedure  Workspace and Mode 

BeginResolve 

Specified workspace: 1WRITER 

MergeWorkspace 

Specified workspace: NO_ACCESS

Parent workspace: READ_ONLY 

CompressWorkspace 

Specified workspace: READ_ONLY (Also, checks to ensure that there are no sessions on savepoints other than LATEST.) 

CreateSavepoint 

Specified workspace: READ_ONLY 

CreateWorkspace 

Specified workspace: READ_ONLY 

RemoveWorkspace 

Specified workspace: NO_ACCESS 

RefreshWorkspace 

Specified workspace: READ_ONLY

Parent workspace: READ_ONLY 

RollbackResolve 

Specified workspace: 1WRITER 

RollbackWorkspace 

Specified workspace: NO_ACCESS 

1.2.7 Removing Workspaces

A workspace can be removed with the RemoveWorkspace procedure. RemoveWorkspace rolls back the data in a workspace and then deletes the workspace structure. An entire tree of workspaces can be removed with the RemoveWorkspaceTree procedure. This will remove the workspace and all its descendant workspaces. A workspace cannot be removed when it has users in it.

1.3 Lock Management

In addition to locks provided by conventional Oracle short transactions, Workspace Manager provides two types of version locks. These locks are primarily intended to eliminate row conflicts between a parent workspace and a child workspace. Locking is enabled at a session level and is a session property independent of the workspace that the session is in. When locking is enabled for a session, it locks rows in all workspaces in which it participates. The two types of version locks are:

Locks persist for the duration of the workspace. Merge or rollback of the workspace removes the locks.

The xxx_LOCK metadata views (described in Section 3.23) contain information about locks in each version-enabled table.

1.4 Privilege Management

Workspace Manager has a set of privileges that are separate from standard Oracle database privileges. Workspace Manager workspace-level privileges (with names in the form xxx_WORKSPACE) allow the user to affect a specified workspace, and system-level privileges (with names in the form xxx_ANY_WORKSPACE) allow the user to affect any workspace.

Table 1-2 lists the Workspace Manager privileges.

Table 1-2 Privileges  
Privilege  Description 

ACCESS_WORKSPACE 

Allows the user to go to a specified workspace. ACCESS_WORKSPACE or ACCESS_ANY_WORKSPACE privilege is needed for all other privileges. 

ACCESS_ANY_WORKSPACE 

Allows the user to go to any workspace. ACCESS_WORKSPACE or ACCESS_ANY_WORKSPACE privilege is needed for all other privileges. 

CREATE_WORKSPACE 

Allows the user to create a child workspace in a specified workspace. 

CREATE_ANY_WORKSPACE 

Allows the user to create a child workspace in any workspace. 

REMOVE_WORKSPACE 

Allows the user to remove a specified workspace. 

REMOVE_ANY_WORKSPACE 

Allows the user to remove any workspace. 

MERGE_WORKSPACE 

Allows the user to merge the changes in a specified workspace to its parent workspace. 

MERGE_ANY_WORKSPACE 

Allows the user to merge the changes in any workspace to its parent workspace. 

ROLLBACK_WORKSPACE 

Allows the user to roll back the changes in a specified workspace. 

ROLLBACK_ANY_WORKSPACE 

Allows the user to roll back the changes in any workspace. 

Each privilege can be granted with or without the grant option. The grant option allows the user to which the privilege is granted to grant the privilege to other users.

The WM_ADMIN_ROLE role has all Workspace Manager privileges with the grant option. By default, the database administrator (DBA role) is granted the WM_ADMIN_ROLE role. Thus, after you decide which users should be granted which privileges, either have the DBA grant the privileges, or have the DBA grant the WM_ADMIN_ROLE role to one or more selected users and have these users grant the privileges.

The GrantWorkspacePriv and GrantSystemPriv procedures are used to grant workspace-level privileges and system-level privileges, respectively.

The RevokeWorkspacePriv and RevokeSystemPriv procedures are used to revoke workspace-level privileges and system-level privileges, respectively. These procedures require that the user have sufficient privilege to revoke the specified privilege from the specified user. The user that granted a privilege can revoke it.

1.5 Import and Export Considerations

Standard Oracle database import and export operations can be performed on version-enabled databases; however, the following considerations and restrictions apply:

1.6 Referential Integrity Support

Version-enabled tables can have referential integrity constraints, including constraints with the CASCADE and RESTRICT options; however, the following considerations and restrictions apply:

Workspace Manager uses the ALL_WM_RIC_INFO and USER_WM_RIC_INFO views (described in Chapter 3) to hold information pertinent to referential integrity support.

1.7 Triggers on Version-Enabled Tables

Version-enabled tables can have triggers defined; however, the following considerations and restrictions apply:

Any triggers that are not supported for version-enabled tables are deactivated when versioning is enabled, and are activated when versioning is disabled.

1.8 Procedure Categories

Workspace Manager provides PL/SQL procedures that you call in order to use the product's features. The procedures are in a single PL/SQL package, but they can be logically grouped into the following categories described in this section.


Note:

Most Workspace Manager interfaces are procedures, but a few are functions. (A function returns a value; a procedure does not return a value.)

Most functions have names starting with Get (such as GetConflictWorkspace and GetWorkspace). 


Reference information for all interfaces is in Chapter 2.

1.8.1 Table Management

Table management procedures enable and disable workspace management on a table.

Table 1-3 shows the procedures available for table management.

Table 1-3 Table Management Procedures
Procedure  Description 

EnableVersioning 

Enables a table for workspace management. 

DisableVersioning 

Removes workspace management capabilities from a table. 

1.8.2 Workspace Management

Workspace management procedures perform operations on workspaces.

Table 1-4 shows the procedures available for workspace management.

Table 1-4 Workspace Management Procedures  
Procedure  Description 

CreateWorkspace 

Creates a new workspace in the database. 

GotoWorkspace 

Adds the user to the specified workspace. 

SetDiffVersions 

Finds differences in values in version-enabled tables for two savepoints and their common ancestor (base). It creates rows in the differences views describing these differences. 

GetDiffVersions 

Returns the names of the (workspace, savepoint) pairs on which the session has performed the SetDiffVersions operation. 

MergeTable 

Applies changes to a table (all rows or as specified in the WHERE clause) in a workspace to its parent workspace. 

MergeWorkspace 

Applies all changes in a workspace to its parent workspace, and optionally removes the workspace. 

RollbackWorkspace 

Discards all changes made in the workspace since the last merge. 

RollbackToSP 

Returns the workspace to a specified savepoint. 

RefreshTable 

Applies to a workspace all changes made to a table (all rows or as specified in the WHERE clause) in its parent workspace. 

RefreshWorkspace 

Applies to a workspace all changes made in its parent workspace. 

AlterWorkspace 

Modifies the description of a workspace. 

RemoveWorkspace 

Rolls back and deletes a workspace. 

RemoveWorkspaceTree 

Deletes a workspace and its descendant workspaces. 

FreezeWorkspace 

Disables changes to a workspace. 

UnfreezeWorkspace 

Enables changes to a workspace after it has been frozen. 

CompressWorkspace 

Deletes explicit savepoints (all or some) in a workspace, and minimizes the Workspace Manager metadata structures. 

CompressWorkspaceTree 

Deletes explicit savepoints in a workspace and all its descendant workspaces, and minimizes the Workspace Manager metadata structures for the affected workspaces. 

IsWorkspaceOccupied 

Checks whether or not a workspace has any active sessions. 

GetWorkspace 

Returns the current workspace for the session. 

1.8.3 Savepoint Management

Savepoint management procedures perform operations related to savepoints.

Table 1-5 shows the procedures available for savepoint management.

Table 1-5 Savepoint Management Procedures
Procedure  Description 

CreateSavepoint 

Creates a new savepoint in the workspace. 

GotoSavepoint 

Goes to the specified savepoint in the current workspace. 

GotoDate 

Goes to a point at or near the specified date and time in the current workspace. 

AlterSavepoint 

Modifies the description of a savepoint. 

DeleteSavepoint 

Deletes a savepoint. 

1.8.4 Privilege Management

Privilege management procedures grant and revoke Workspace Manager privileges.

Table 1-6 shows the procedures available for privilege management.

Table 1-6 Privilege Management Procedures
Procedure  Description 

GrantWorkspacePriv 

Grants workspace-level privileges to users, roles, or PUBLIC

RevokeWorkspacePriv 

Revokes workspace-level privileges. 

GrantSystemPriv 

Grants privileges on all workspaces to users, roles, or PUBLIC

RevokeSystemPriv 

Revokes system-level privileges. 

GetPrivs 

Returns a comma-separated list of all privileges that the current user has for the specified workspace. 

1.8.5 Lock Management

Lock management procedures control Workspace Manager locking.

Table 1-7 shows the procedures available for lock management.

Table 1-7 Lock Management Procedures
Procedure  Description 

SetLockingON 

Turns locking on for the current session. 

SetLockingOFF 

Turns locking off for the current session. 

SetWorkspaceLockModeON 

Sets the default mode for the row-level locking in the workspace. 

SetWorkspaceLockModeOFF 

Enables access to versioned rows in the specified workspace and to corresponding rows in the parent workspace. 

GetLockMode 

Returns the locking mode, which determines whether or not access is enabled to versioned rows and corresponding rows in the parent workspace. 

LockRows 

Disables access to versioned rows in a specified table and to corresponding rows in the parent workspace 

UnlockRows 

Enables access to versioned rows in a specified table and to corresponding rows in the parent workspace. 

1.8.6 Conflict Management

Conflict management procedures detect and resolve conflicts between workspaces.

Table 1-8 shows the procedures available for conflict management.

Table 1-8 Conflict Management Procedures
Procedure  Description 

SetConflictWorkspace 

Determines the conflicts between a workspace and its parent. 

GetConflictWorkspace 

Returns the name of the workspace on which the session has performed the SetConflictWorkspace procedure. 

BeginResolve 

Starts a conflict resolution session. 

ResolveConflicts 

Resolves conflicts between workspaces. 

CommitResolve 

Ends a conflict resolution session and saves changes. 

RollbackResolve 

Quits a conflict resolution session and does not save changes. 

SetMultiWorkspaces 

Makes the specified workspace or workspaces visible in the multiworkspace views for version-enabled tables. 

GetMultiWorkspaces 

Returns the names of workspaces visible in the multiworkspace views for version-enabled tables. 

1.9 Simplified Example

This section presents a simplified example of using Workspace Manager to try out some scenarios. It refers to concepts that were explained in this chapter, and it uses procedures documented in Chapter 2.

In Example 1-1, a soft drink (cola) manufacturer has four products, each with a marketing manager and a marketing budget. Because of an exceptional opportunity for growth in one (cola_b) market, the company wants to do "what-if" analyses involving different managers and budget amounts.

Example 1-1 Simplified Example Using Workspace Manager

-------------------------------------------------------------------
-- INITIAL SET-UP
-------------------------------------------------------------------
-- Create the user for schema objects.
CREATE USER wm_developer IDENTIFIED BY wm_developer;

-- Grant regular privileges.
GRANT connect, resource to wm_developer;
GRANT create table to wm_developer;

-- Grant WM-specific privileges (with grant_option = YES).
EXECUTE DBMS_WM.GrantSystemPriv ('ACCESS_ANY_WORKSPACE, MERGE_ANY_WORKSPACE,
 CREATE_ANY_WORKSPACE, REMOVE_ANY_WORKSPACE, ROLLBACK_ANY_WORKSPACE',  
 'wm_developer', 'YES');

---------------------------------------------------------------------------
-- CREATE AND POPULATE DATA TABLE --
---------------------------------------------------------------------------
CONNECT wm_developer/wm_developer

-- Cleanup: remove B_focus_2 workspace if it exists from previous run.
EXECUTE DBMS_WM.RemoveWorkspace ('B_focus_2');

-- Create a table for the annual marketing budget for
-- several cola (soft drink) markets in a
-- given geography (such as city or state).
-- Each row will contain budget data for a specific
-- cola. Note: This table does not reflect recommended
-- database design. (For example, a manager ID should
-- be used, not a name.) It is deliberately oversimplified
-- for purposes of illustration.

CREATE TABLE cola_marketing_budget (
  mkt_id NUMBER PRIMARY KEY,
  mkt_name VARCHAR2(32),
  manager VARCHAR2(32),  -- Here a name, just for simplicity
  budget NUMBER  -- Budget in millions of dollars. Example: 3 = $3,000,000.
);

-- Version-enable the table. Specify hist option of VIEW_WO_OVERWRITE so that
-- the COLA_MARKETING_BUDGET_HIST view contains complete history information.
EXECUTE DBMS_WM.EnableVersioning ('cola_marketing_budget', 'VIEW_WO_OVERWRITE');

INSERT INTO cola_marketing_budget VALUES(
  1,
  'cola_a',
  'Alvarez',
  2.0
);
INSERT INTO cola_marketing_budget VALUES(
  2,
  'cola_b',
  'Baker',
  1.5
);
INSERT INTO cola_marketing_budget VALUES(
  3,
  'cola_c',
  'Chen',
  1.5
);
INSERT INTO cola_marketing_budget VALUES(
  4,
  'cola_d',
  'Davis',
  3.5
);
COMMIT;

-- Relevant data values now in LIVE workspace:
-- cola_a, Alvarez, 2.0
-- cola_b, Baker, 1.5
-- cola_c, Chen, 1.5
-- cola_d, Davis, 3.5

---------------------------------------------------------------------------
-- CREATE WORKSPACES --
---------------------------------------------------------------------------
-- Create workspaces for the following scenario: a major marketing focus
-- in the cola_b area. Managers and budget amounts for each
-- market can change, but the total marketing budget cannot grow.
--
-- One scenario (B_focus_1) features a manager with more expensive 
-- plans (which means more money taken from other areas' budgets).
-- The other scenario (B_focus_2) features a manager with less expensive 
-- plans (which means less money taken from other areas' budgets).
--
-- Two workspaces (B_focus_1 and B_focus_2) are created as child workspaces 
-- of the LIVE database workspace.

EXECUTE DBMS_WM.CreateWorkspace ('B_focus_1');
EXECUTE DBMS_WM.CreateWorkspace ('B_focus_2');

---------------------------------------------------------------------------
-- WORK IN FIRST WORKSPACE --
---------------------------------------------------------------------------
-- Enter the B_focus_1 workspace and change the cola_b manager to Beasley and 
-- raise the cola_b budget amount by 1.5 to bring it to 3.0. Reduce all other 
-- area budget amounts by 0.5 to stay within the overall budget.

EXECUTE DBMS_WM.GotoWorkspace ('B_focus_1');
UPDATE cola_marketing_budget
  SET manager = 'Beasley' WHERE mkt_name = 'cola_b';
UPDATE cola_marketing_budget
  SET budget = 3 WHERE mkt_name = 'cola_b';
UPDATE cola_marketing_budget
  SET budget = 1.5 WHERE mkt_name = 'cola_a';
UPDATE cola_marketing_budget
  SET budget = 1 WHERE mkt_name = 'cola_c';
UPDATE cola_marketing_budget
  SET budget = 3 WHERE mkt_name = 'cola_d';
COMMIT;

-- Relevant data values now in B_focus_1 workspace::
-- cola_a, Alvarez, 1.5
-- cola_b, Beasley, 3.0
-- cola_c, Chen, 1.0
-- cola_d, Davis, 3.0

-- Freeze this workspace. (Prevent any changes until workspace is unfrozen.)
-- However, first go to the LIVE workspace, because a workspace cannot be
-- frozen if any users (including you) are in it.
EXECUTE DBMS_WM.GotoWorkspace ('LIVE');
EXECUTE DBMS_WM.FreezeWorkspace ('B_focus_1');

---------------------------------------------------------------------------
-- WORK IN SECOND WORKSPACE --
---------------------------------------------------------------------------
-- Enter the B_focus_2 workspace and change the cola_b manager to Burton and 
-- raise the cola_b budget amount by 0.5 to bring it to 2.0. Reduce only the 
-- cola_d amount by 0.5 to stay within the overall budget.

EXECUTE DBMS_WM.GotoWorkspace ('B_focus_2');
UPDATE cola_marketing_budget
  SET manager = 'Burton' WHERE mkt_name = 'cola_b';
UPDATE cola_marketing_budget
  SET budget = 2 WHERE mkt_name = 'cola_b';
UPDATE cola_marketing_budget
  SET budget = 3 WHERE mkt_name = 'cola_d';
COMMIT;

-- Relevant data values now in B_focus_2 workspace::
-- cola_a, Alvarez, 2.0 (no change from LIVE)
-- cola_b, Burton, 2.0
-- cola_c, Chen, 1.5 (no change from LIVE)
-- cola_d, Davis, 3.0 (same manager, new budget)

-- Create a savepoint (B_focus_2_SP1), then change scenario to 
-- raise cola_b budget and reduce cola_d budget by 0.5 each.

EXECUTE DBMS_WM.CreateSavepoint ('B_focus_2', 'B_focus_2_SP1');
UPDATE cola_marketing_budget
  SET budget = 2.5 WHERE mkt_name = 'cola_b';
UPDATE cola_marketing_budget
  SET budget = 2.5 WHERE mkt_name = 'cola_d';
COMMIT;

-- Relevant data values now in B_focus_2 workspace:
-- cola_a, Alvarez, 2.0 (no change from LIVE)
-- cola_b, Burton, 2.5 
-- cola_c, Chen, 1.5 (no change from LIVE)
-- cola_d, Davis, 2.5 (same manager, new budget)

-- Discard this scenario; rollback to row values at the time savepoint 
-- B_focus_2_SP1 was created. First, though, get out of the workspace
-- so it can be rolled back (no users in it).

EXECUTE DBMS_WM.GotoWorkspace ('LIVE');
EXECUTE DBMS_WM.RollbackToSP ('B_focus_2', 'B_focus_2_SP1');

-- Go back to the B_focus_2 workspace and display current values 
-- (should include budget of 2 for cola_b and 3 for cola_d).
SELECT * FROM cola_marketing_budget;

---------------------------------------------------------------------------
-- SELECT SCENARIO AND UPDATE DATABASE --
---------------------------------------------------------------------------
-- Assume that you have decided to adopt the scenario of the second 
-- workspace (B_focus_2) using that workspace's current values.

-- First go to the LIVE workspace, because the other cannot be removed
-- or merged if any users (including you) are in it.
EXECUTE DBMS_WM.GotoWorkspace ('LIVE');

-- Unfreeze the first workspace and remove it to discard any changes there.
EXECUTE DBMS_WM.UnfreezeWorkspace ('B_focus_1');
EXECUTE DBMS_WM.RemoveWorkspace ('B_focus_1');

-- Apply changes in the second workspace to the LIVE database workspace.
-- Note that the workspace is removed by default after MergeWorkspace.
EXECUTE DBMS_WM.MergeWorkspace ('B_focus_2');

-- Display the current data values (which are in the LIVE database 
-- workspace, which is the only workspace currently existing).
SELECT * FROM cola_marketing_budget;

---------------------------------------------------------------------------
-- DISABLE VERSIONING --
---------------------------------------------------------------------------
-- Disable versioning on the table because you are finished testing scenarios.
-- Also, users with version enabled tables cannot be dropped, in case you
-- want to drop the wm_developer user.
-- Set force parameter to TRUE if you want to force the disabling even
-- if changes were made in a non-LIVE workspace.

EXECUTE DBMS_WM.DisableVersioning ('cola_marketing_budget', TRUE);


Go to previous page Go to next page
Oracle
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.

Home

Book List

Contents

Index

Master Index

Feedback