Search Results erase_saved_version




Overview

OKC_VERSION_PVT is a private PL/SQL package body in the Oracle E-Business Suite ETRM (Enterprise Contracts) module. It implements the internal versioning engine that governs the lifecycle of contract versions in the OKC schema, and it is registered in EBS as a private API (classification PVT). The package exposes the low-level logic required to create a new version of a contract, to save an in-progress version, to erase or delete a previously saved version, and — the topic of principal interest — to restore a contract back to an older version. As a private package, it is not intended for direct invocation by external integrators; instead it is called by the public OKC APIs, by the Contracts forms, and by other packages within the Contracts application stack. The source header identifies the originating bug fixes (Bug# 1553916, Bug 3431701) and notes that the versioning logic applies to contracts in any status, including saving an active contract for update and restoring to a prior version.

Key Procedures and Functions

ETRM documents six procedures and functions within this package. The following summarizes their purpose; parameter lists are defined by the package specification and are not reproduced here.

  • VERSION_CONTRACT — Creates a new version of a contract, assigning the version numbering that the OKC versioning model requires. It is the entry point used when an existing contract must be branched into a new version.
  • SAVE_VERSION — Persists the current working state of a contract as a saved version. This corresponds to the case where a contract is opened for update in Active status and the user elects to save the result as a version.
  • ERASE_SAVED_VERSION — Removes a saved version that is no longer needed, typically a version that has not yet been promoted or that must be discarded during editing.
  • RESTORE_VERSION — Restores the contract to an earlier version. This is the procedure the user most likely encountered when searching for "restore_version." It reconstructs the contract's data from the version history tables and re-establishes the target version as the current one.
  • DELETE_VERSION — Deletes a version from the contract's version history, distinct from merely erasing a saved (uncommitted) version.
  • SET_ATTACH_SESSION_VARS — A helper that establishes session-level variables tied to attachments, added under Bug 3431701, so that attachment operations during versioning resolve against the correct contract.

The package also contains a private helper, version_attachments, which manages attachments across version, save, and restore operations, and internal cursors (c_major_ver, c_lines, c_rest_to_ver) that resolve the current major version, the affected contract lines, and the version to which a restore is targeted.

Tables Accessed

The documented table references show that OKC_VERSION_PVT operates across the contract condition and contact structures. OKC_CONDITION_HEADERS_B and its history sibling OKC_CONDITION_HEADERS_BH, together with OKC_CONDITION_HEADERS_TL and OKC_CONDITION_HEADERS_TLH, hold condition headers and their translation and historical forms; OKC_CONDITION_LINES_B, _BH, _TL, and _TLH hold the corresponding condition lines. OKC_CLASS_OPERATIONS records the operation definitions used to determine what actions a contract class permits. OKC_FUNCTION_EXPR_PARAMS and its history table support rule/function expressions embedded in conditions. OKC_CONTACTS and OKC_CONTACTS_H store contract contacts and their history, and OKC_COVER_TIMES and OKC_COVER_TIMES_H hold contract coverage periods. In addition, the source excerpt references OKC_K_VERS_NUMBERS and OKC_K_VERS_NUMBERS_H, which carry the major/minor version numbering used to identify and restore versions, and OKC_K_LINES_B, which supplies the contract lines affected by a version operation. The history (_H, _BH, _TLH) tables are read during RESTORE_VERSION to recover prior-state rows.

Usage Notes

Because OKC_VERSION_PVT is a private package, it is invoked indirectly rather than called directly by customers or partners. Typical invocations originate from the Contracts workbench forms, from the public OKC contract APIs (which delegate versioning to this private layer), and from concurrent programs that perform bulk contract maintenance. ETRM records that the package is referenced by 49 other packages, confirming its position as a shared internal service. Custom code should call the supported public OKC APIs rather than OKC_VERSION_PVT directly; calling the private package bypasses validation, message handling, and the OKC_API activity framework that the package relies on for return status and error propagation. When diagnosing version or restore behavior, the version-numbering cursors and the history tables listed above are the primary data sources. The restore path specifically depends on OKC_K_VERS_NUMBERS_H being populated for the target major version, so missing or purged history rows are a common cause of restore failures.