The DBMS_TRANSACTION package provides access to SQL transaction statements from stored procedures.
See Also:
Oracle Database SQL Language ReferenceThis chapter contains the following topics:
Security Model
Table 153-1 DBMS_TRANSACTION Package Subprograms
Subprogram | Description |
---|---|
Equivalent to the SQL statement:
|
|
Equivalent to the SQL statement:
|
|
Equivalent to the SQL statement:
|
|
Equivalent to the SQL statement:
|
|
Equivalent to the SQL statement:
|
|
Equivalent to the SQL statement:
|
|
Returns the local (to instance) unique identifier for the current transaction |
|
Enables removal of incomplete transactions from the local site when the remote database is destroyed or re-created before recovery completes |
|
Deletes information about a given mixed outcome transaction |
|
Equivalent to the SQL statement:
|
|
equivalent to the SQL statement:
|
|
Equivalent to the SQL statement:
|
|
Equivalent to the SQL statement:
|
|
Equivalent to the SQL statement:
|
|
Equivalent to the SQL statement:
|
|
Returns local (to local transaction) unique positive integer that orders the DML operations of a transaction |
|
Equivalent to the SQL statement:
|
This procedure is equivalent to the SQL statement:
ALTER SESSION ADVISE COMMIT
This procedure is equivalent to the SQL statement:
ALTER SESSION ADVISE NOTHING
This procedure is equivalent to the SQL statement:
ALTER SESSION ADVISE ROLLBACK
This procedure is equivalent to the SQL statement:
COMMIT
This procedure is included for completeness, the functionality being already implemented as part of PL/SQL.
This procedure is equivalent to the SQL statement:
COMMIT FORCE <text>, <number>"
This function returns the local (to instance) unique identifier for the current transaction. It returns null if there is no current transaction.
DBMS_TRANSACTION.LOCAL_TRANSACTION_ID ( create_transaction BOOLEAN := FALSE) RETURN VARCHAR2;
When a failure occurs during commit processing, automatic recovery consistently resolves the results at all sites involved in the transaction. However, if the remote database is destroyed or re-created before recovery completes, then the entries used to control recovery in DBA_2PC_PENDING
and associated tables are never removed, and recovery will periodically retry. Procedure PURGE_LOST_DB_ENTRY
enables removal of such transactions from the local site.
WARNING:
PURGE_LOST_DB_ENTRY should only be used when the other database is lost or has been re-created. Any other use may leave the other database in an unrecoverable or inconsistent state.
Before automatic recovery runs, the transaction may show up in DBA_2PC_PENDING
as state "collecting", "committed", or "prepared". If the DBA has forced an in-doubt transaction to have a particular result by using "commit force" or "rollback force", then states "forced commit" or "forced rollback" may also appear. Automatic recovery normally deletes entries in any of these states. The only exception is when recovery finds a forced transaction which is in a state inconsistent with other sites in the transaction; in this case, the entry is left in the table and the MIXED
column has the value 'yes'.
However, under certain conditions, it may not be possible for automatic recovery to run. For example, a remote database may have been permanently lost. Even if it is re-created, it gets a new database ID, so that recovery cannot identify it (a possible symptom is ORA-02062
). In this case, the DBA may use the procedure PURGE_LOST_DB_ENTRY
to clean up the entries in any state other than "prepared". The DBA does not need to be in any particular hurry to resolve these entries, because they are not holding any database resources.
The following table indicates what the various states indicate about the transaction and what the DBA actions should be:
Table 153-6 PURGE_LOST_DB_ENTRY Procedure States
State of Column | State of Global Transaction | State of Local Transaction | Normal DBA Action | Alternative DBA Action |
---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NOTE 1:
Use only if significant reconfiguration has occurred so that automatic recovery cannot resolve the transaction. Examples are total loss of the remote database, reconfiguration in software resulting in loss of two-phase commit capability, or loss of information from an external transaction coordinator such as a TP monitor.NOTE 2:
Examine and take any manual action to remove inconsistencies; then use the procedurePURGE_MIXED
.When in-doubt transactions are forced to commit or rollback (instead of letting automatic recovery resolve their outcomes), there is a possibility that a transaction can have a mixed outcome: Some sites commit, and others rollback. Such inconsistency cannot be resolved automatically by Oracle; however, Oracle flags entries in DBA_2PC_PENDING
by setting the MIXED
column to a value of 'yes'.
Oracle never automatically deletes information about a mixed outcome transaction. When the application or DBA is certain that all inconsistencies that might have arisen as a result of the mixed transaction have been resolved, this procedure can be used to delete the information about a given mixed outcome transaction.
This procedure is equivalent to the SQL statement:
ROLLBACK
This procedure is included for completeness, the functionality being already implemented as part of PL/SQL.
This procedure is equivalent to the SQL statement:
ROLLBACK TO SAVEPOINT <savepoint_name>
This procedure is included for completeness, the functionality being already implemented as part of PL/SQL.
This procedure is equivalent to the SQL statement:
SAVEPOINT <savepoint_name>
This procedure is included for completeness, the feature being already implemented as part of PL/SQL.
This function returns local (to local transaction) unique positive integer that orders the DML operations of a transaction.