Oracle® Database PL/SQL Packages and Types Reference 11g Release 2 (11.2) Part Number E10577-04 |
|
|
View PDF |
The DBMS_APPLY_ADM
package, one of a set of Oracle Streams packages, provides subprograms to configure and manage Oracle Streams apply processes.
This chapter contains the following topic:
Overview
Operational Notes
See Also:
Oracle Streams Concepts and Administration and Oracle Streams Replication Administrator's Guide for more information about this package and apply processesThis section contains topics which relate to using the DBMS_APPLY_ADM
package.
This package provides interfaces to start, stop, and configure an apply process. This package includes subprograms for configuring apply handlers, setting enqueue destinations for messages, and specifying execution directives for messages. This package also provides administrative subprograms that set the instantiation SCN for objects at a destination database. This package also includes subprograms for managing apply errors.
The following sections contain operational notes for this package:
Note:
Oracle recommends that you do not use deprecated apply process parameter values. Support for deprecated features is for backward compatibility only.The NONE
value for the commit_serialization
apply process parameter is deprecated. It is replaced by the DEPENDENT_TRANSACTIONS
value.
See Also:
"SET_PARAMETER Procedure"Table 20-1 DBMS_APPLY_ADM Package Subprograms
Subprogram | Description |
---|---|
Adds a statement DML handler for a specified operation on a specified database object to a single Oracle Streams apply process or to all apply processes in the database |
|
Alters an Oracle Streams apply process |
|
Specifies whether to compare the old value of one or more columns in a row logical change record (row LCR) with the current value of the corresponding columns at the destination site during apply |
|
Creates an apply process |
|
Creates an object dependency |
|
Deletes all the error transactions for the specified apply process |
|
Deletes the specified error transaction |
|
Drops an apply process |
|
Drops an object dependency |
|
Reexecutes the error transactions for the specified apply process. |
|
Reexecutes the specified error transaction |
|
Returns the message payload from the error queue for the specified message number and transaction identifier |
|
Removes a statement DML handler for a specified operation on a specified database object from a single apply process or from all apply processes in the database |
|
Sets or unsets a statement DML handler that tracks changes for a specified operation on a specified database object for a single apply process |
|
Sets a user procedure as a procedure DML handler for a specified operation on a specified database object for a single apply process or for all apply processes in the database |
|
Sets the queue where the apply process automatically enqueues a message that satisfies the specified rule |
|
Specifies whether a message that satisfies the specified rule is executed by an apply process |
|
Records the specified instantiation SCN for the specified source database and, optionally, for the schemas at the source database and the tables owned by these schemas |
|
Records the set of columns to be used as the substitute primary key for local apply purposes and removes existing substitute primary key columns for the specified object if they exist |
|
Sets an apply parameter to the specified value |
|
Records the specified instantiation SCN for the specified schema in the specified source database and, optionally, for the tables owned by the schema at the source database |
|
Records the specified instantiation SCN for the specified table in the specified source database |
|
Adds, updates, or drops an update conflict handler for the specified object |
|
Sets or removes a value dependency |
|
Directs the apply process to start applying messages |
|
Stops the apply process from applying any messages and rolls back any unfinished transactions being applied |
Note:
All procedures commit unless specified otherwise. However, theGET_ERROR_MESSAGE
function does not commit.This procedure adds a statement DML handler for a specified operation on a specified database object to a single Oracle Streams apply process or to all apply processes in the database.
This procedure is overloaded. One version of this procedure contains the statement
and comment
parameters, and the other does not. The statement
parameter enables you to create the statement DML handler and add it to one or more apply processes in one step. Otherwise, create the statement DML handler using the DBMS_STREAMS_HANDLER_ADM
package before adding it to one or more apply processes.
Syntax
DBMS_APPLY_ADM.ADD_STMT_HANDLER( object_name IN VARCHAR2, operation_name IN VARCHAR2, handler_name IN VARCHAR2, statement IN CLOB, apply_name IN VARCHAR2 DEFAULT NULL, comment IN VARCHAR2 DEFAULT NULL); DBMS_APPLY_ADM.ADD_STMT_HANDLER( object_name IN VARCHAR2, operation_name IN VARCHAR2, handler_name IN VARCHAR2, apply_name IN VARCHAR2 DEFAULT NULL);
Parameters
Table 20-2 ADD_STMT_HANDLER Procedure Parameters
Parameter | Description |
---|---|
|
The name of the source object specified as If |
|
The name of the operation, which can be specified as:
If Note: Statement DML handlers cannot be specified for LOB operations. |
|
The name of the statement DML handler. If the specified statement DML handler exists, then the statement in the If the specified statement DML handler does not exist and a non- If the specified statement DML handler does not exist and the If |
|
The text of the SQL statement to add to the statement DML handler. If |
|
The name of the apply process that uses the statement DML handler. If |
|
A comment for the statement DML handler. If |
This procedure alters an Oracle Streams apply process.
Syntax
DBMS_APPLY_ADM.ALTER_APPLY( apply_name IN VARCHAR2, rule_set_name IN VARCHAR2 DEFAULT NULL, remove_rule_set IN BOOLEAN DEFAULT FALSE, message_handler IN VARCHAR2 DEFAULT NULL remove_message_handler IN BOOLEAN DEFAULT FALSE, ddl_handler IN VARCHAR2 DEFAULT NULL, remove_ddl_handler IN BOOLEAN DEFAULT FALSE, apply_user IN VARCHAR2 DEFAULT NULL, apply_tag IN RAW DEFAULT NULL, remove_apply_tag IN BOOLEAN DEFAULT FALSE, precommit_handler IN VARCHAR2 DEFAULT NULL, remove_precommit_handler IN BOOLEAN DEFAULT FALSE, negative_rule_set_name IN VARCHAR2 DEFAULT NULL, remove_negative_rule_set IN BOOLEAN DEFAULT FALSE);
Parameters
Table 20-3 ALTER_APPLY Procedure Parameters
Parameter | Description |
---|---|
|
The name of the apply process being altered. You must specify the name of an existing apply process. Do not specify an owner. |
|
The name of the positive rule set for the apply process. The positive rule set contains the rules that instruct the component to apply messages. If you want to use a positive rule set for the component, then you must specify an existing rule set in the form An error is returned if the specified rule set does not exist. You can create a rule set and add rules to it using the If you specify |
|
If If you remove the positive rule set for a component, and a negative rule set exists for the component, then the component dequeues all messages in its queue that are not discarded by the negative rule set. If If the |
|
A user-defined procedure that processes non-LCR messages in the queue for the apply process. See "Usage Notes" in the CREATE_APPLY Procedure for more information about a message handler procedure. |
|
If If If the |
|
A user-defined procedure that processes DDL logical change records (DDL LCRs) in the queue for the apply process. All applied DDL LCRs commit automatically. Therefore, if a DDL handler calls the See "Usage Notes" in the CREATE_APPLY Procedure for more information about a DDL handler procedure. |
|
If If If the |
|
The user in whose security domain an apply process dequeues messages that satisfy its rule sets, applies messages directly to database objects, runs custom rule-based transformations configured for apply process rules, and runs apply handlers configured for the apply process. If If a non- If you change the apply user, then this procedure grants the new apply user dequeue privilege on the queue used by the apply process and configures the user as a secure queue user of the queue. In addition to the privileges granted by this procedure, you also should grant the following privileges to the apply user:
These privileges can be granted directly to the apply user, or they can be granted through roles. In addition, the apply user must be granted By default, this parameter is set to the user who created the apply process by running either the Note: If the specified user is dropped using |
|
A binary tag that is added to redo entries generated by the specified apply process. The tag is a binary value that can be used to track LCRs. The tag is relevant only if a capture process at the database where the apply process is running will capture changes made by the apply process. If so, then the captured changes will include the tag specified by this parameter. If The following is an example of a tag with a hexadecimal value of
See Also: Oracle Streams Replication Administrator's Guide for more information about tags |
|
If If If the |
|
A user-defined procedure that can receive internal commit directives in the queue for the apply process before they are processed by the apply process. Typically, precommit handlers are used for auditing commit information for transactions processed by an apply process. An internal commit directive is enqueued in the following ways:
For a captured row LCR, a commit directive contains the commit SCN of the transaction from the source database. For a user message, the commit SCN is generated by the apply process. The precommit handler procedure must conform to the following restrictions:
If a precommit handler raises an exception, then the entire apply transaction is rolled back, and all of the messages in the transaction are moved to the error queue. See "Usage Notes" in the CREATE_APPLY Procedure for more information about a precommit handler procedure. |
|
If If If the |
|
The name of the negative rule set for the apply process. The negative rule set contains the rules that instruct the apply process to discard messages. If you want to use a negative rule set for the apply process, then you must specify an existing rule set in the form An error is returned if the specified rule set does not exist. You can create a rule set and add rules to it using the If you specify If you specify both a positive and a negative rule set for an apply process, then the negative rule set is always evaluated first. |
|
If If you remove the negative rule set for an apply process, and a positive rule set exists for the apply process, then the apply process dequeues all messages in its queue that are not discarded by the positive rule set. If If the |
Usage Notes
An apply process is stopped and restarted automatically when you change the value of one or more of the following ALTER_APPLY
procedure parameters:
message_handler
ddl_handler
apply_user
apply_tag
precommit_handler
This procedure specifies whether to compare the old value of one or more columns in a row logical change record (row LCR) with the current value of the corresponding columns at the destination site during apply. This procedure is relevant only for UPDATE
and DELETE
operations because only these operations result in old column values in row LCRs. The default is to compare old values for all columns.
This procedure is overloaded. The column_list
and column_table
parameters are mutually exclusive.
See Also:
Oracle Streams Replication Administrator's Guide for more information about conflict detection and resolution in an Oracle Streams environmentSyntax
DBMS_APPLY_ADM.COMPARE_OLD_VALUES( object_name IN VARCHAR2, column_list IN VARCHAR2, operation IN VARCHAR2 DEFAULT 'UPDATE', compare IN BOOLEAN DEFAULT TRUE, apply_database_link IN VARCHAR2 DEFAULT NULL); DBMS_APPLY_ADM.COMPARE_OLD_VALUES( object_name IN VARCHAR2, column_table IN DBMS_UTILITY.LNAME_ARRAY, operation IN VARCHAR2 DEFAULT 'UPDATE', compare IN BOOLEAN DEFAULT TRUE, apply_database_link IN VARCHAR2 DEFAULT NULL);
Parameters
Table 20-4 COMPARE_OLD_VALUES Procedure Parameters
Parameter | Description |
---|---|
|
The name of the source table specified as |
|
A comma-delimited list of column names in the table. There must be no spaces between entries. Specify |
|
A PL/SQL index-by table of type |
|
The name of the operation, which can be specified as:
|
|
If |
|
The name of the database link to a non-Oracle database. This parameter should be set only when the destination database is a non-Oracle database. |
Usage Notes
By default, an apply process uses the old column values in a row LCR to detect conflicts. You can choose not to compare old column values to avoid conflict detection for specific tables. For example, if you use a time column for conflict detection, then an apply process does not need to check old values for non-key and nontime columns.
Note:
An apply process always compares old values for key columns when they are present in a row LCR. This procedure raises an error if a key column is specified incolumn_list
or column_table
and the compare
parameter is set to FALSE
.This procedure creates an apply process.
Note:
The user who invokes this procedure must be grantedDBA
role.Syntax
DBMS_APPLY_ADM.CREATE_APPLY( queue_name IN VARCHAR2, apply_name IN VARCHAR2, rule_set_name IN VARCHAR2 DEFAULT NULL, message_handler IN VARCHAR2 DEFAULT NULL, ddl_handler IN VARCHAR2 DEFAULT NULL, apply_user IN VARCHAR2 DEFAULT NULL, apply_database_link IN VARCHAR2 DEFAULT NULL, apply_tag IN RAW DEFAULT '00', apply_captured IN BOOLEAN DEFAULT FALSE, precommit_handler IN VARCHAR2 DEFAULT NULL, negative_rule_set_name IN VARCHAR2 DEFAULT NULL, source_database IN VARCHAR2 DEFAULT NULL);
Parameters
Table 20-5 CREATE_APPLY Procedure Parameters
Parameter | Description |
---|---|
|
The name of the queue from which the apply process dequeues messages. You must specify an existing queue in the form Note: The |
|
The name of the apply process being created. A The specified name must not match the name of an existing apply process or messaging client. Note: The |
|
The name of the positive rule set for the apply process. The positive rule set contains the rules that instruct the apply process to apply messages. If you want to use a positive rule set for the apply process, then you must specify an existing rule set in the form If you specify An error is returned if the specified rule set does not exist. You can create a rule set and add rules to it using the |
|
A user-defined procedure that processes non-LCR messages in the queue for the apply process. See "Usage Notes" for more information about a message handler procedure. |
|
A user-defined procedure that processes DDL logical change record (DDL LCRs) in the queue for the apply process. All applied DDL LCRs commit automatically. Therefore, if a DDL handler calls the See "Usage Notes" for more information about a DDL handler procedure. |
|
The user who applies all DML and DDL changes that satisfy the apply process rule sets and who runs user-defined apply handlers. If Only a user who is granted The apply user is the user in whose security domain an apply process dequeues messages that satisfy its rule sets, applies messages directly to database objects, runs custom rule-based transformations configured for apply process rules, and runs apply handlers configured for the apply process. This user must have the necessary privileges to apply changes. This procedure grants the apply user dequeue privilege on the queue used by the apply process and configures the user as a secure queue user of the queue. In addition to the privileges granted by this procedure, you also should grant the following privileges to the apply user:
These privileges can be granted directly to the apply user, or they can be granted through roles. In addition, the apply user must be granted Note: If the specified user is dropped using |
|
The database at which the apply process applies messages. This parameter is used by an apply process when applying changes from Oracle to non-Oracle systems, such as Sybase. Set this parameter to Note: The |
|
A binary tag that is added to redo entries generated by the specified apply process. The tag is a binary value that can be used to track LCRs. The tag is relevant only if a capture process at the database where the apply process is running will capture changes made by the apply process. If so, then the captured changes will include the tag specified by this parameter. By default, the tag for an apply process is the hexadecimal equivalent of The following is an example of a tag with a hexadecimal value of HEXTORAW('17') If See Also: Oracle Streams Replication Administrator's Guide for more information about tags |
|
Either If If To apply both captured LCRs and messages in a persistent queue, you must create at least two apply processes. Note: The See Also: Oracle Streams Concepts and Administration for more information about processing messages with an apply process |
|
A user-defined procedure that can receive internal commit directives in the queue for the apply process before they are processed by the apply process. Typically, precommit handlers are used for auditing commit information for transactions processed by an apply process. An internal commit directive is enqueued in the following ways:
For a row LCR captured by a capture process or synchronous capture, a commit directive contains the commit SCN of the transaction from the source database. For message enqueued by a user or application, the commit SCN is generated by the apply process. The precommit handler procedure must conform to the following restrictions:
If a precommit handler raises an exception, then the entire apply transaction is rolled back, and all of the messages in the transaction are moved to the error queue. See "Usage Notes" for more information about a precommit handler procedure. |
|
The name of the negative rule set for the apply process. The negative rule set contains the rules that instruct the apply process to discard messages. If you want to use a negative rule set for the apply process, then you must specify an existing rule set in the form If you specify An error is returned if the specified rule set does not exist. You can create a rule set and add rules to it using the If you specify both a positive and a negative rule set for an apply process, then the negative rule set is always evaluated first. |
|
The global name of the source database for the changes that will be applied by the apply process. The source database is the database where the changes originated. If an apply process applies captured messages, then the apply process can apply messages from only one capture process at one source database. If If you do not include the domain name, then the procedure appends it to the database name automatically. For example, if you specify The rules in the apply process rule sets determine which messages are dequeued by the apply process. If the apply process dequeues an LCR with a source database that is different than the source database for the apply process, then an error is raised. You can determine the source database for an apply process by querying the |
Usage Notes
The following sections describe usage notes for this procedure:
Handler Procedure Names
For the message_handler
, ddl_handler
, and precommit_handler
parameters, specify an existing procedure in one of the following forms:
[schema_name.]procedure_name
[schema_name.]package_name.procedure_name
If the procedure is in a package, then the package_name must be specified. For example, to specify a procedure in the apply_pkg
package in the hr
schema named process_ddls
, enter hr.apply_pkg.process_ddls
. An error is returned if the specified procedure does not exist.
The user who invokes the CREATE_APPLY
procedure must have EXECUTE
privilege on a specified handler procedure. Also, if the schema_name
is not specified, then the user who invokes the CREATE_APPLY
procedure is the default.
Message Handler and DDL Handler Procedure
The procedure specified in both the message_handler
parameter and the ddl_handler
parameter must have the following signature:
PROCEDURE handler_procedure ( parameter_name IN ANYDATA);
Here, handler_procedure
stands for the name of the procedure and parameter_name
stands for the name of the parameter passed to the procedure. For the message handler, the parameter passed to the procedure is a ANYDATA
encapsulation of a user message. For the DDL handler procedure, the parameter passed to the procedure is a ANYDATA
encapsulation of a DDL LCR.
See Also:
Chapter 245, "Logical Change Record TYPEs" for information about DDL LCRsPrecommit Handler Procedure
The procedure specified in the precommit_handler
parameter must have the following signature:
PROCEDURE handler_procedure ( parameter_name IN NUMBER);
Here, handler_procedure
stands for the name of the procedure and parameter_name
stands for the name of the parameter passed to the procedure. The parameter passed to the procedure is the commit SCN of a commit directive.
This procedure creates an object dependency. An object dependency is a virtual dependency definition that defines a parent-child relationship between two objects at a destination database.
An apply process schedules execution of transactions that involve the child object after all transactions with a lower commit system change number (commit SCN) that involve the parent object have been committed. An apply process uses the object identifier of the objects in the logical change records (LCRs) to detect dependencies. The apply process does not use column values in the LCRs to detect dependencies.
Note:
An error is raised ifNULL
is specified for either of the procedure parameters.Syntax
DBMS_APPLY_ADM.CREATE_OBJECT_DEPENDENCY( object_name IN VARCHAR2, parent_object_name IN VARCHAR2);
Parameters
Table 20-6 CREATE_OBJECT_DEPENDENCY Procedure Parameters
Parameter | Description |
---|---|
|
The name of the child database object, specified as |
|
The name of the parent database object, specified as |
This procedure deletes all the error transactions for the specified apply process.
Syntax
DBMS_APPLY_ADM.DELETE_ALL_ERRORS( apply_name IN VARCHAR2 DEFAULT NULL);
Parameter
Table 20-7 DELETE_ALL_ERRORS Procedure Parameter
Parameter | Description |
---|---|
|
The name of the apply process that raised the errors while processing the transactions. Do not specify an owner. If |
This procedure deletes the specified error transaction.
Syntax
DBMS_APPLY_ADM.DELETE_ERROR( local_transaction_id IN VARCHAR2);
Parameter
Table 20-8 DELETE_ERROR Procedure Parameter
Parameter | Description |
---|---|
|
The identification number of the error transaction to delete. If the specified transaction does not exist in the error queue, then an error is raised. |
This procedure drops an apply process.
Syntax
DBMS_APPLY_ADM.DROP_APPLY( apply_name IN VARCHAR2, drop_unused_rule_sets IN BOOLEAN DEFAULT FALSE);
Parameters
Table 20-9 DROP_APPLY Procedure Parameters
Parameter | Description |
---|---|
|
The name of the apply process being dropped. You must specify an existing apply process name. Do not specify an owner. |
|
If If |
Usage Notes
When you use this procedure to drop an apply process, information about rules created for the apply process using the DBMS_STREAMS_ADM
package is removed from the data dictionary views for Oracle Streams rules. Information about such a rule is removed even if the rule is not in either the positive or negative rule set for the apply process. The following are the data dictionary views for Oracle Streams rules:
ALL_STREAMS_GLOBAL_RULES
DBA_STREAMS_GLOBAL_RULES
ALL_STREAMS_MESSAGE_RULES
DBA_STREAMS_MESSAGE_RULES
ALL_STREAMS_SCHEMA_RULES
DBA_STREAMS_SCHEMA_RULES
ALL_STREAMS_TABLE_RULES
DBA_STREAMS_TABLE_RULES
See Also:
Oracle Streams Concepts and Administration for more information about Oracle Streams data dictionary viewsThis procedure drops an object dependency. An object dependency is a virtual dependency definition that defines a parent-child relationship between two objects at a destination database.
Note:
An error is raised if an object dependency does not exist for the specified database objects.
An error is raised if NULL
is specified for either of the procedure parameters.
Syntax
DBMS_APPLY_ADM.DROP_OBJECT_DEPENDENCY( object_name IN VARCHAR2, parent_object_name IN VARCHAR2);
Parameters
Table 20-10 DROP_OBJECT_DEPENDENCY Procedure Parameters
Parameter | Description |
---|---|
|
The name of the child database object, specified as |
|
The name of the parent database object, specified as |
This procedure reexecutes the error transactions in the error queue for the specified apply process.
The transactions are reexecuted in commit SCN order. Error reexecution stops if an error is raised.
See Also:
Oracle Streams Concepts and Administration for more information about the error queueSyntax
DBMS_APPLY_ADM.EXECUTE_ALL_ERRORS( apply_name IN VARCHAR2 DEFAULT NULL, execute_as_user IN BOOLEAN DEFAULT FALSE);
Parameters
Table 20-11 EXECUTE_ALL_ERRORS Procedure Parameters
Parameter | Description |
---|---|
|
The name of the apply process that raised the errors while processing the transactions. Do not specify an owner. If |
|
If If The user who executes the transactions must have privileges to perform DML and DDL changes on the apply objects and to run any apply handlers. This user must also have dequeue privileges on the queue used by the apply process. |
This procedure reexecutes the specified error transaction in the error queue.
See Also:
Oracle Streams Concepts and Administration for more information about the error queueSyntax
DBMS_APPLY_ADM.EXECUTE_ERROR( local_transaction_id IN VARCHAR2, execute_as_user IN BOOLEAN DEFAULT FALSE, user_procedure IN VARCHAR2 DEFAULT NULL);
Parameters
Table 20-12 EXECUTE_ERROR Procedure Parameters
Parameter | Description |
---|---|
|
The identification number of the error transaction to execute. If the specified transaction does not exist in the error queue, then an error is raised. |
|
If If The user who executes the transaction must have privileges to perform DML and DDL changes on the apply objects and to run any apply handlers. This user must also have dequeue privileges on the queue used by the apply process. |
|
A user-defined procedure that modifies the error transaction so that it can be successfully executed. Specify See Also: "Usage Notes" for more information about the user procedure |
Usage Notes
You must specify the full procedure name for the user_procedure
parameter in one of the following forms:
[
schema_name
.]
package_name.procedure_name
[
schema_name
.]
procedure_name
If the procedure is in a package, then the package_name
must be specified. The user who invokes the EXECUTE_ERROR
procedure must have EXECUTE
privilege on the specified procedure. Also, if the schema_name
is not specified, then the user who invokes the EXECUTE_ERROR
procedure is the default.
For example, suppose the procedure_name
has the following properties:
strmadmin
is the schema_name
.
fix_errors
is the package_name
.
fix_hr_errors
is the procedure_name
.
In this case, specify the following:
strmadmin.fix_errors.fix_hr_errors
The procedure you create for error handling must have the following signature:
PROCEDURE user_procedure (
in_anydata IN ANYDATA,
error_record IN DBA_APPLY_ERROR%ROWTYPE,
error_message_number IN NUMBER,
messaging_default_processing IN OUT BOOLEAN,
out_anydata OUT ANYDATA);
The user procedure has the following parameters:
in_anydata
: The ANYDATA
encapsulation of a message that the apply process passes to the procedure. A single transaction can include multiple messages. A message can be a row logical change record (row LCR), a DDL logical change record (DDL LCR), or a user message.
error_record
: The row in the DBA_APPLY_ERROR
data dictionary view that identifies the transaction
error_message_number
: The message number of the ANYDATA
object in the in_anydata
parameter, starting at 1
messaging_default_processing
: If TRUE
, then the apply process continues processing the message in the in_anydata
parameter, which can include executing DML or DDL statements and invoking apply handlers.
If FALSE
, then the apply process skips processing the message in the in_anydata
parameter and moves on to the next message in the in_anydata
parameter.
out_anydata
: The ANYDATA
object processed by the user procedure and used by the apply process if messaging_default_processing
is TRUE
.
If an LCR is executed using the EXECUTE
LCR member procedure in the user procedure, then the LCR is executed directly, and the messaging_default_processing
parameter should be set to FALSE
. In this case, the LCR is not passed to any apply handlers.
Processing an error transaction with a user procedure results in one of the following outcomes:
The user procedure modifies the transaction so that it can be executed successfully.
The user procedure fails to make the necessary modifications, and an error is raised when transaction execution is attempted. In this case, the transaction is rolled back and remains in the error queue.
The following restrictions apply to the user procedure:
Do not execute COMMIT
or ROLLBACK
statements. Doing so can endanger the consistency of the transaction.
Do not modify LONG
, LONG
RAW
or LOB column data in an LCR.
If the ANYDATA
object in the in_anydata
parameter is a row LCR, then the out_anydata
parameter must be row LCR if the messaging_default_processing
parameter is set to TRUE
.
If the ANYDATA
object in the in_anydata
parameter is a DDL LCR, then the out_anydata
parameter must be DDL LCR if the messaging_default_processing
parameter is set to TRUE
.
The user who runs the user procedure must have SELECT
privilege on the DBA_APPLY_ERROR
data dictionary view.
Note:
LCRs containing transactional directives, such asCOMMIT
and ROLLBACK
, are not passed to the user procedure.This function returns the message payload from the error queue for the specified message number and transaction identifier. The message can be a logical change record (LCR) or a non-LCR message.
This function is overloaded. One version of this function contains two OUT
parameters. These OUT
parameters contain the destination queue into which the message should be enqueued, if one exists, and whether or not the message should be executed. The destination queue is specified using the SET_ENQUEUE_DESTINATION
procedure, and the execution directive is specified using the SET_EXECUTE
procedure.
Syntax
DBMS_APPLY_ADM.GET_ERROR_MESSAGE( message_number IN NUMBER, local_transaction_id IN VARCHAR2, destination_queue_name OUT VARCHAR2, execute OUT BOOLEAN) RETURN ANYDATA; DBMS_APPLY_ADM.GET_ERROR_MESSAGE( message_number IN NUMBER, local_transaction_id IN VARCHAR2) RETURN ANYDATA;
Parameters
Table 20-13 GET_ERROR_MESSAGE Function Parameters
Parameter | Description |
---|---|
|
The identification number of the message. This number identifies the position of the message in the transaction. Query the |
|
Identifier of the error transaction for which to return a message |
|
Contains the name of the queue into which the message should be enqueued. If the message should not be enqueued into a queue, then this parameter contains |
|
Contains Contains |
This procedure removes a statement DML handler for a specified operation on a specified database object from a single apply process or from all apply processes in the database.
Syntax
DBMS_APPLY_ADM.REMOVE_STMT_HANDLER( object_name IN VARCHAR2, operation_name IN VARCHAR2, handler_name IN VARCHAR2, apply_name IN VARCHAR2 DEFAULT NULL);
Parameters
Table 20-14 REMOVE_STMT_HANDLER Procedure Parameters
Parameter | Description |
---|---|
|
The name of the source object specified as If |
|
The name of the operation, which can be specified as:
If |
|
The name of the statement DML handler. If |
|
The name of the apply process that uses the statement DML handler. If |
This procedure sets or unsets a change handler that tracks changes for a specified operation on a specified database object for a single apply process.
A change handler is a special type of statement DML handler that tracks table changes and was created by either the DBMS_STREAMS_ADM.MAINTAIN_CHANGE_TABLE
procedure or this SET_CHANGE_HANDLER
procedure. Information about change handlers is stored in the ALL_APPLY_CHANGE_HANDLERS
and DBA_APPLY_CHANGE_HANDLERS
views.
This procedure automatically generates the statement that is added to the change handler based on values specified in the procedure parameters. You should only run this procedure when an Oracle Streams environment that tracks database changes already exists.
Note:
Use the MAINTAIN_CHANGE_TABLE Procedure to create an Oracle Streams environment that tracks table changesSyntax
DBMS_APPLY_ADM.SET_CHANGE_HANDLER( change_table_name IN VARCHAR2, source_table_name IN VARCHAR2, capture_values IN VARCHAR2, apply_name IN VARCHAR2, operation_name IN VARCHAR2, change_handler_name IN VARCHAR2 DEFAULT NULL);
Parameters
Table 20-15 SET_CHANGE_HANDLER Procedure Parameters
Parameter | Description |
---|---|
|
The table that records changes to the source table. Specify the table as If |
|
The table at the source database for which changes are recorded. Specify the table as If |
|
Specify which values to record in the change table when update operations are performed on the source table:
If Note: For insert operations, only new column values are captured. For delete operations, only old column values are captured. |
|
The name of the apply process that applies changes to the change table. Do not specify an owner. If |
|
The name of the operation, which can be specified as:
If Note: Change handlers cannot be specified for LOB operations. |
|
The name of the change handler. If the specified change handler exists, then a statement is added to the existing handler. Ensure that the existing change handler is for the same operation on the same table as the settings for the If non- If If See Also: "Usage Notes" for more information about this parameter. |
Usage Notes
To check for an existing change handler for a specific operation on a specific source table, run the following query:
SELECT HANDLER_NAME, APPLY_NAME FROM DBA_APPLY_CHANGE_HANDLERS WHERE operation_name = 'operation' AND source_table_owner = 'source_table_owner' AND source_table_name = 'source_table_name' AND change_table_owner = 'change_table_owner' AND change_table_name = 'change_table_name';
where:
operation is operation specified for the new handler, either INSERT
, UPDATE
, or DELETE
source_table_owner is the owner of the source table
source_table_name is the name of the source table
change_table_owner is the owner of the change table
change_table_owner is the owner of the change table
This procedure sets or unsets a user procedure as a procedure DML handler for a specified operation on a specified database object for a single apply process or for all apply processes in the database. The user procedure alters the apply behavior for the specified operation on the specified object.
Syntax
DBMS_APPLY_ADM.SET_DML_HANDLER( object_name IN VARCHAR2, object_type IN VARCHAR2, operation_name IN VARCHAR2, error_handler IN BOOLEAN DEFAULT FALSE, user_procedure IN VARCHAR2, apply_database_link IN VARCHAR2 DEFAULT NULL, apply_name IN VARCHAR2 DEFAULT NULL, assemble_lobs IN BOOLEAN DEFAULT TRUE);
Parameters
Table 20-16 SET_DML_HANDLER Procedure Parameters
Parameter | Description |
---|---|
|
The name of the source object specified as |
|
The type of the source object. Currently, |
|
The name of the operation, which can be specified as:
For example, suppose you run this procedure twice for the Specify |
|
If If |
|
A user-defined procedure that is invoked during apply for the specified operation on the specified object. If the procedure is a procedure DML handler, then it is invoked instead of the default apply performed by Oracle. If the procedure is an error handler, then it is invoked when the apply process encounters an error. Specify |
|
The name of the database link to a non-Oracle database. This parameter should be set only when the destination database is a non-Oracle database. |
|
The name of the apply process that uses the procedure DML handler or error handler. If If the |
|
If If |
Usage Notes
Run this procedure at the destination database. The SET_DML_HANDLER
procedure provides a way for users to apply logical change records containing DML changes (row LCRs) using a customized apply.
If the error_handler
parameter is set to TRUE
, then it specifies that the user procedure is an error handler. An error handler is invoked only when a row LCR raises an apply process error. Such an error can result from a data conflict if no conflict handler is specified or if the update conflict handler cannot resolve the conflict. If the error_handler
parameter is set to FALSE
, then the user procedure is a procedure DML handler, not an error handler, and a procedure DML handler is always run instead of performing the specified operation on the specified object.
This procedure either sets a procedure DML handler or an error handler for a particular operation on an object. It cannot set both a procedure DML handler and an error handler for the same object and operation.
If the apply_name
parameter is non-NULL
, then the procedure DML handler or error handler is set for the specified apply process. In this case, this handler is not invoked for other apply processes at the local destination database. If the apply_name
parameter is NULL
, the default, then the handler is set as a general handler for all apply processes at the destination database. When a handler is set for a specific apply process, then this handler takes precedence over any general handlers. For example, consider the following scenario:
A procedure DML handler named handler_hr
is specified for an apply process named apply_hr
for UPDATE
operations on the hr.employees
table.
A general procedure DML handler named handler_gen
also exists for UPDATE
operations on the hr.employees
table.
In this case, the apply_hr
apply process uses the handler_hr
procedure DML handler for UPDATE
operations on the hr.employees
table.
At the source database, you must specify an unconditional supplemental log group for the columns needed by a DML or error handler.
Attention:
Do not modifyLONG
, LONG
RAW
, or nonassembled LOB column data in an LCR with procedure DML handlers, error handlers, or custom rule-based transformation functions. Procedure DML handlers and error handlers can modify LOB columns in row LCRs that have been constructed by LOB assembly.Note:
Currently, setting an error handler for an apply process that is applying changes to a non-Oracle database is not supported.The SET_DML_HANDLER
procedure can be used to set either a procedure DML handler or an error handler for row LCRs that perform a specified operation on a specified object. The signatures of a DML handler procedure and of an error handler procedure are described following this section.
In either case, you must specify the full procedure name for the user_procedure
parameter in one of the following forms:
[
schema_name
.]
package_name.procedure_name
[
schema_name
.]
procedure_name
If the procedure is in a package, then the package_name
must be specified. The user who invokes the SET_DML_HANDLER
procedure must have EXECUTE
privilege on the specified procedure. Also, if the schema_name
is not specified, then the user who invokes the SET_DML_HANDLER
procedure is the default.
For example, suppose the procedure_name
has the following properties:
hr
is the schema_name
.
apply_pkg
is the package_name
.
employees_default
is the procedure_name
.
In this case, specify the following:
hr.apply_pkg.employees_default
The following restrictions apply to the user procedure:
Do not execute COMMIT
or ROLLBACK
statements. Doing so can endanger the consistency of the transaction that contains the LCR.
If you are manipulating a row using the EXECUTE
member procedure for the row LCR, then do not attempt to manipulate more than one row in a row operation. You must construct and execute manually any DML statements that manipulate more than one row.
If the command type is UPDATE
or DELETE
, then row operations resubmitted using the EXECUTE
member procedure for the LCR must include the entire key in the list of old values. The key is the primary key or the smallest unique index that has at least one NOT
NULL
column, unless a substitute key has been specified by the SET_KEY_COLUMNS
procedure. If there is no specified key, then the key consists of all non LOB
, non LONG
, and non LONG
RAW
columns.
If the command type is INSERT
, then row operations resubmitted using the EXECUTE
member procedure for the LCR should include the entire key in the list of new values. Otherwise, duplicate rows are possible. The key is the primary key or the smallest unique index that has at least one NOT
NULL
column, unless a substitute key has been specified by the SET_KEY_COLUMNS
procedure. If there is no specified key, then the key consists of all of the table columns, except for columns of the following data types: LOB, LONG
, LONG
RAW
, user-defined types (including object types, REF
s, varrays, nested tables), and Oracle-supplied types (including Any
types, XML types, spatial types, and media types).
See Also:
Oracle Streams Replication Administrator's Guide for information about and restrictions regarding procedure DML handlers and LOB,LONG
, and LONG
RAW
data typesThe procedure specified in the user_procedure
parameter must have the following signature:
PROCEDURE user_procedure ( parameter_name IN ANYDATA);
Here, user_procedure
stands for the name of the procedure and parameter_name
stands for the name of the parameter passed to the procedure. The parameter passed to the procedure is a ANYDATA
encapsulation of a row LCR.
See Also:
Chapter 245, "Logical Change Record TYPEs" for more information about LCRsThe procedure you create for error handling must have the following signature:
PROCEDURE user_procedure (
message IN ANYDATA,
error_stack_depth IN NUMBER,
error_numbers IN DBMS_UTILITY.NUMBER_ARRAY,
error_messages IN emsg_array);
If you want to retry the DML operation within the error handler, then have the error handler procedure run the EXECUTE
member procedure for the LCR. The last error raised is on top of the error stack. To specify the error message at the top of the error stack, use error_numbers(1)
and error_messages(1)
.
Note:
Each parameter is required and must have the specified data type. However, you can change the names of the parameters.
The emsg_array
value must be a user-defined array that is a table of type VARCHAR2
with at least 76 characters.
Running an error handler results in one of the following outcomes:
The error handler successfully resolves the error and returns control to the apply process.
The error handler fails to resolve the error, and the error is raised. The raised error causes the transaction to be rolled back and placed in the error queue.
This procedure sets the queue where the apply process automatically enqueues a message that satisfies the specified rule.
This procedure modifies the specified rule's action context to specify the queue. A rule action context is optional information associated with a rule that is interpreted by the client of the rules engine after the rule evaluates to TRUE
for a message. In this case, the client of the rules engine is an Oracle Streams apply process. The information in an action context is an object of type SYS.RE$NV_LIST
, which consists of a list of name-value pairs.
A queue destination specified by this procedure always consists of the following name-value pair in an action context:
The name is APPLY$_ENQUEUE
.
The value is a ANYDATA
instance containing the queue name specified as a VARCHAR2
.
Syntax
DBMS_APPLY_ADM.SET_ENQUEUE_DESTINATION( rule_name IN VARCHAR2, destination_queue_name IN VARCHAR2);
Parameters
Table 20-17 SET_ENQUEUE_DESTINATION Procedure Parameters
Parameter | Description |
---|---|
|
The name of the rule, specified as |
|
The name of the queue into which the apply process should enqueue the message. Specify the queue in the form For example, to specify a queue in the If If non- |
Usage Notes
If an apply handler, such as a procedure DML handler, DDL handler, or message handler, processes a message that also is enqueued into a destination queue, then the apply handler processes the message before it is enqueued.
The following are considerations for using this procedure:
This procedure does not verify that the specified queue exists. If the queue does not exist, then an error is raised when an apply process tries to enqueue a message into it.
Oracle Streams capture processes, propagations, and messaging clients ignore the action context created by this procedure.
The apply user of the apply processes using the specified rule must have the necessary privileges to enqueue messages into the specified queue. If the queue is a secure queue, then the apply user must be a secure queue user of the queue.
The specified rule must be in the positive rule set for an apply process. If the rule is in the negative rule set for an apply process, then the apply process does not enqueue the message into the destination queue.
If the commit SCN for a message is less than or equal to the relevant instantiation SCN for the message, then the message is not enqueued into the destination queue, even if the message satisfies the apply process rule sets.
This procedure specifies whether a message that satisfies the specified rule is executed by an apply process.
This procedure modifies the specified rule's action context to specify message execution. A rule action context is optional information associated with a rule that is interpreted by the client of the rules engine after the rule evaluates to TRUE
for a message. In this case, the client of the rules engine is an Oracle Streams apply process. The information in an action context is an object of type SYS.RE$NV_LIST
, which consists of a list of name-value pairs.
A message execution directive specified by this procedure always consists of the following name-value pair in an action context:
The name is APPLY$_EXECUTE
.
The value is a ANYDATA
instance that contains NO
as a VARCHAR2
. When the value is NO
, then an apply process does not execute the message and does not send the message to any apply handler.
Syntax
DBMS_APPLY_ADM.SET_EXECUTE( rule_name IN VARCHAR2, execute IN BOOLEAN);
Parameters
Table 20-18 SET_EXECUTE Procedure Parameters
Parameter | Description |
---|---|
|
The name of the rule, specified as |
|
If If If |
Usage Notes
If the message is a logical change record (LCR) and the message is not executed, then the change encapsulated in the LCR is not made to the relevant local database object. Also, if the message is not executed, then it is not sent to any apply handler.
Note:
Oracle Streams capture processes, propagations, and messaging clients ignore the action context created by this procedure.
The specified rule must be in the positive rule set for an apply process for the apply process to follow the execution directive. If the rule is in the negative rule set for an apply process, then the apply process ignores the execution directive for the rule.
This procedure records the specified instantiation SCN for the specified source database and, optionally, for the schemas at the source database and the tables owned by these schemas. This procedure overwrites any existing instantiation SCN for the database, and, if it sets the instantiation SCN for a schema or a table, then it overwrites any existing instantiation SCN for the schema or table.
This procedure gives you precise control over which DDL logical change records (DDL LCRs) from a source database are ignored and which DDL LCRs are applied by an apply process.
Syntax
DBMS_APPLY_ADM.SET_GLOBAL_INSTANTIATION_SCN( source_database_name IN VARCHAR2, instantiation_scn IN NUMBER, apply_database_link IN VARCHAR2 DEFAULT NULL, recursive IN BOOLEAN DEFAULT FALSE);
Parameters
Table 20-19 SET_GLOBAL_INSTANTIATION_SCN Procedure Parameters
Parameter | Description |
---|---|
|
The global name of the source database. For example, If you do not include the domain name, then the procedure appends it to the database name automatically. For example, if you specify |
|
The instantiation SCN. Specify |
|
The name of the database link to a non-Oracle database. This parameter should be set only when the destination database of a local apply process is a non-Oracle database. |
|
If If Note: If |
Usage Notes
If the commit SCN of a DDL LCR for a database object from a source database is less than or equal to the instantiation SCN for that source database at a destination database, then the apply process at the destination database disregards the DDL LCR. Otherwise, the apply process applies the DDL LCR.
The global instantiation SCN specified by this procedure is used for a DDL LCR only if the DDL LCR does not have object_owner
, base_table_owner
, and base_table_name
specified. For example, the global instantiation SCN set by this procedure is used for DDL LCRs with a command_type
of CREATE
USER
.
If the recursive
parameter is set to TRUE
, then this procedure sets the instantiation SCN for each schema at a source database and for the tables owned by these schemas. This procedure uses the SET_SCHEMA_INSTANTIATION_SCN
procedure to set the instantiation SCN for each schema, and it uses the SET_TABLE_INSTANTIATION_SCN
procedure to set the instantiation SCN for each table. Each schema instantiation SCN is used for DDL LCRs on the schema, and each table instantiation SCN is used for DDL LCRs and row LCRs on the table.
If the recursive
parameter is set to FALSE
, then this procedure does not set the instantiation SCN for any schemas or tables.
Note:
Any instantiation SCN specified by this procedure is used only for LCRs captured by a capture process. It is not used for user-created LCRs.
The instantiation SCN is not set for the SYS
or SYSTEM
schemas.
See Also:
"LCR$_DDL_RECORD Type" for more information about DDL LCRs
This procedure records the set of columns to be used as the substitute primary key for apply purposes and removes existing substitute primary key columns for the specified object if they exist.
This procedure is overloaded. The column_list
and column_table
parameters are mutually exclusive.
Syntax
DBMS_APPLY_ADM.SET_KEY_COLUMNS( object_name IN VARCHAR2, column_list IN VARCHAR2, apply_database_link IN VARCHAR2 DEFAULT NULL); DBMS_APPLY_ADM.SET_KEY_COLUMNS( object_name IN VARCHAR2, column_table IN DBMS_UTILITY.NAME_ARRAY, apply_database_link IN VARCHAR2 DEFAULT NULL);
Parameters
Table 20-20 SET_KEY_COLUMNS Procedure Parameters
Parameter | Description |
---|---|
|
The name of the table specified as |
|
A comma-delimited list of the columns in the table that you want to use as the substitute primary key, with no spaces between the column names. If the |
|
A PL/SQL index-by table of type If the |
|
The name of the database link to a non-Oracle database. This parameter should be set only when the destination database is a non-Oracle database. |
Usage Notes
When not empty, this set of columns takes precedence over any primary key for the specified object. Do not specify substitute key columns if the object already has primary key columns and you want to use those primary key columns as the key.
Run this procedure at the destination database. At the source database, you must specify an unconditional supplemental log group for the substitute key columns.
Note:
Unlike true primary keys, columns specified as substitute key column columns can contain NULL
s. However, Oracle recommends that each column you specify as a substitute key column be a NOT
NULL
column. You also should create a single index that includes all of the columns in a substitute key. Following these guidelines improves performance for updates, deletes, and piecewise updates to LOBs because Oracle can locate the relevant row more efficiently.
You should not permit applications to update the primary key or substitute key columns of a table. This ensures that Oracle can identify rows and preserve the integrity of the data.
If there is neither a primary key, nor a unique index that has at least one NOT
NULL
column, nor a substitute key for a table, then the key consists of all of the table columns, except for columns of the following data types: LOB, LONG
, LONG
RAW
, user-defined types (including object types, REF
s, varrays, nested tables), and Oracle-supplied types (including Any
types, XML types, spatial types, and media types).
This procedure sets an apply parameter to the specified value.
Syntax
DBMS_APPLY_ADM.SET_PARAMETER ( apply_name IN VARCHAR2, parameter IN VARCHAR2, value IN VARCHAR2 DEFAULT NULL);
Parameters
Table 20-21 SET_PARAMETER Procedure Parameters
Parameter | Description |
---|---|
|
The apply process name. Do not specify an owner. |
|
The name of the parameter you are setting. See "Apply Process Parameters" for a list of these parameters. |
|
The value to which the parameter is set. If |
Apply Process Parameters
The following table lists the parameters for the apply process.
Table 20-22 Apply Process Parameters
Parameter Name | Possible Values | Default | Description |
---|---|---|---|
|
|
If If Note: Regardless of the setting for this parameter, apply processes do not allow changes to duplicate rows for tables with LOB, See Also: "Duplicate Rows and Substitute Primary Key Columns" |
|
|
|
The order in which applied transactions are committed. Apply servers can apply nondependent transactions at the destination database in an order that is different from the commit order at the source database. Dependent transactions are always applied at the destination database in the same order as they were committed at the source database. You control whether the apply servers can apply nondependent transactions in a different order at the destination database using the
Regardless of the specification, applied transactions can execute in parallel subject to data dependencies and constraint dependencies. If you specify
At the destination database, these transactions might be committed in the opposite order:
If you specify Note: The |
|
|
|
If If |
|
|
|
If If When an apply process is restarted, it gets a new session identifier, and the processes associated with the apply process also get new session identifiers. However, the coordinator process number ( |
|
A valid SCN or |
|
The apply process is disabled before applying a transaction with a commit SCN greater than or equal to the value specified. If |
|
A positive integer |
|
The number of apply servers that can concurrently apply transactions. The reader server and the apply server process names are For example, if parallelism is set to Setting the Note: When the value of this parameter is changed from |
|
|
|
Whether to preserve encryption for columns encrypted using transparent data encryption. If If Note: When the value of this parameter is changed for a running apply process, the apply process is stopped and restarted automatically. This can take some time depending on the size of the transactions currently being applied. |
|
|
|
Whether to remove blank padding from the right end of a column when automatic data type conversion is performed during apply. If If See Also: Oracle Streams Concepts and Administration for information about automatic data type conversion during apply |
|
|
|
The maximum number of seconds to wait for another instantiation of the same apply process to finish. If the other instantiation of the same apply process does not finish within this time, then the apply process does not start. If |
|
A positive integer or |
|
The apply process stops as soon as possible after the specified number of seconds since it started. If |
|
|
|
Set this parameter only under the guidance of Oracle Support Services. |
|
A positive integer or |
|
The apply process stops after applying the specified number of transactions. If |
|
A positive integer or |
|
The apply process begins to spill messages from memory to hard disk for a particular transaction when the amount of time that any message in the transaction has been in memory exceeds the specified number. The parameter specifies the age in seconds. When the reader server spills messages from memory, the messages are stored in a database table on the hard disk. These messages are not spilled from memory to a queue table. Message spilling occurs at the transaction level. For example, if this parameter is set to If Query the |
|
A positive integer or |
|
The apply process begins to spill messages from memory to hard disk for a particular transaction when the number of messages in memory for the transaction exceeds the specified number. The number of messages in first chunk of messages spilled from memory equals the number specified for this parameter, and the number of messages spilled in future chunks is either 100 or the number specified for this parameter, whichever is less. If the reader server of an apply process has the specified number of messages in memory for a particular transaction, then when it detects the next message for this transaction, it spills the messages that are in memory to the hard disk. For example, if this parameter is set to
The apply process applies the first 10,100 messages from the hard disk and the last 100 messages from memory. When the reader server spills messages from memory, the messages are stored in a database table on the hard disk. These messages are not spilled from memory to a queue table. Message spilling occurs at the transaction level. For example, if this parameter is set to If Query the |
|
|
|
|
If If The message specifies the reason why the apply process stopped. |
Usage Notes
When you alter a parameter value, a short amount of time might pass before the new value for the parameter takes effect.
Note:
For all parameters that are interpreted as positive integers, the maximum possible value is 4,294,967,295
. Where applicable, specify INFINITE
for larger values.
For parameters that require an SCN setting, any valid SCN value can be specified.
Duplicate Rows and Substitute Primary Key Columns
A table has duplicate rows when the all of the column values are identical for two or more rows in the table, excluding LOB, LONG
, and LONG
RAW
columns. You can specify substitute primary key columns for a table at a destination database using by the SET_KEY_COLUMNS
procedure. When substitute primary key columns are specified for a table with duplicate rows at a destination database, and the allow_duplicate_rows
apply process parameter is set to Y
, meet the following requirements to keep the table data synchronized at the source and destination databases:
Ensure that updates at the source database always update at least one of the columns specified as a substitute key column at the destination database.
Ensure that the substitute key columns uniquely identify each row in the table at the destination database.
The rest of this section provides more details about these requirements.
If a table does not have a primary key, a unique index that has at least one NOT
NULL
column, or a substitute key, then the key consists of all non LOB, non LONG
, and non LONG
RAW
columns. When there is no key for a table and the allow_duplicate_rows
apply process parameter is set to Y
, a single row LCR with an UPDATE
or DELETE
command type only is applied to one of the duplicate rows. In this case, if the table at the source database and the table at the destination database have corresponding duplicate rows, then a change that changes all of the duplicate rows at the source database also changes all the duplicate rows at the destination database when the row LCRs resulting from the change are applied.
For example, suppose a table at a source database has two duplicate rows. An update is performed on the duplicate rows, resulting in two row LCRs. At the destination database, one row LCR is applied to one of the duplicate rows. At this point, the rows are no longer duplicate at the destination database because one of the rows has changed. When the second row LCR is applied at the destination database, the rows are duplicate again. Similarly, if a delete is performed on these duplicate rows at the source database, then both rows are deleted at the destination database when the row LCRs resulting from the source change are applied.
When substitute primary key columns are specified for a table, row LCRs are identified with rows in the table during apply using the substitute primary key columns. If substitute primary key columns are specified for a table with duplicate rows at a destination database, and the allow_duplicate_rows
apply process parameter is set to Y
, then an update performed on duplicate rows at the source database can result in different changes when the row LCRs are applied at the destination database. Specifically, if the update does not change one of the columns specified as a substitute primary key column, then the same duplicate row can be updated multiple times at the destination database, while other duplicate rows might not be updated.
Also, if the substitute key columns do not identify each row in the table at the destination database uniquely, then a row LCR identified with multiple rows can update any one of the rows. In this case, the update in the row LCR might not be applied to the correct row in the table at the destination database.
An apply process ignores substitute primary key columns when it determines whether rows in a table are duplicates. An apply process determines that rows are duplicates only if all of the column values in the rows are identical (excluding LOB, LONG
, and LONG
RAW
columns). Therefore, an apply process always raises an error if a single update or delete changes two or more nonduplicate rows in a table.
For example, consider a table with columns c1
, c2
, and c3
on which the SET_KEY_COLUMNS
procedure is used to designate column c1
as the substitute primary key. If two rows have the same key value for the c1
column, but different value for the c2
or c3
columns, then an apply process does not treat the rows as duplicates. If an update or delete modifies more than one row because the c1
values in the rows are the same, then the apply process raises an error regardless of the setting for the allow_duplicate_rows
apply process parameter.
See Also:
"SET_KEY_COLUMNS Procedures"This procedure records the specified instantiation SCN for the specified schema in the specified source database and, optionally, for the tables owned by the schema at the source database. This procedure overwrites any existing instantiation SCN for the schema, and, if it sets the instantiation SCN for a table, it overwrites any existing instantiation SCN for the table.
This procedure gives you precise control over which DDL logical change records (LCRs) for a schema are ignored and which DDL LCRs are applied by an apply process.
Syntax
DBMS_APPLY_ADM.SET_SCHEMA_INSTANTIATION_SCN( source_schema_name IN VARCHAR2, source_database_name IN VARCHAR2, instantiation_scn IN NUMBER, apply_database_link IN VARCHAR2 DEFAULT NULL, recursive IN BOOLEAN DEFAULT FALSE);
Parameters
Table 20-23 SET_SCHEMA_INSTANTIATION_SCN Procedure Parameters
Parameter | Description |
---|---|
|
The name of the source schema. For example, When setting an instantiation SCN for schema, always specify the name of the schema at the source database, even if a rule-based transformation or apply handler is configured to change the schema name. |
|
The global name of the source database. For example, If you do not include the domain name, then the procedure appends it to the database name automatically. For example, if you specify |
|
The instantiation SCN. Specify |
|
The name of the database link to a non-Oracle database. This parameter should be set only when the destination database of a local apply process is a non-Oracle database. |
|
If If Note: If |
Usage Notes
If the commit SCN of a DDL LCR for a database object in a schema from a source database is less than or equal to the instantiation SCN for that database object at a destination database, then the apply process at the destination database disregards the DDL LCR. Otherwise, the apply process applies the DDL LCR.
The schema instantiation SCN specified by this procedure is used on the following types of DDL LCRs:
DDL LCRs with a command_type
of CREATE
TABLE
DDL LCRs with a non-NULL
object_owner
specified and neither base_table_owner
nor base_table_name
specified.
For example, the schema instantiation SCN set by this procedure is used for a DDL LCR with a command_type
of CREATE
TABLE
and ALTER
USER
.
The schema instantiation SCN specified by this procedure is not used for DDL LCRs with a command_type
of CREATE
USER
. A global instantiation SCN is needed for such DDL LCRs.
If the recursive
parameter is set to TRUE
, then this procedure sets the table instantiation SCN for each table at the source database owned by the schema. This procedure uses the SET_TABLE_INSTANTIATION_SCN
procedure to set the instantiation SCN for each table. Each table instantiation SCN is used for DDL LCRs and row LCRs on the table.
If the recursive
parameter is set to FALSE
, then this procedure does not set the instantiation SCN for any tables.
Note:
Any instantiation SCN specified by this procedure is used only for LCRs captured by a capture process. It is not used for user-created LCRs.See Also:
"LCR$_DDL_RECORD Type" for more information about DDL LCRs
This procedure records the specified instantiation SCN for the specified table in the specified source database. This procedure overwrites any existing instantiation SCN for the particular table.
This procedure gives you precise control over which logical change records (LCRs) for a table are ignored and which LCRs are applied by an apply process.
Syntax
DBMS_APPLY_ADM.SET_TABLE_INSTANTIATION_SCN( source_object_name IN VARCHAR2, source_database_name IN VARCHAR2, instantiation_scn IN NUMBER, apply_database_link IN VARCHAR2 DEFAULT NULL);
Parameters
Table 20-24 SET_TABLE_INSTANTIATION_SCN Procedure Parameters
Parameter | Description |
---|---|
|
The name of the source object specified as When setting an instantiation SCN for a database object, always specify the name of the schema and database object at the source database, even if a rule-based transformation or apply handler is configured to change the schema name or database object name. |
|
The global name of the source database. For example, If you do not include the domain name, then the procedure appends it to the database name automatically. For example, if you specify |
|
The instantiation SCN. Specify |
|
The name of the database link to a non-Oracle database. This parameter should be set only when the destination database of a local apply process is a non-Oracle database. |
Usage Notes
If the commit SCN of an LCR for a table from a source database is less than or equal to the instantiation SCN for that table at some destination database, then the apply process at the destination database disregards the LCR. Otherwise, the apply process applies the LCR.
The table instantiation SCN specified by this procedure is used on the following types of LCRs:
Row LCRs for the table
DDL LCRs that have a non-NULL
base_table_owner
and base_table_name
specified, except for DDL LCRs with a command_type
of CREATE
TABLE
For example, the table instantiation SCN set by this procedure is used for DDL LCRs with a command_type
of ALTER
TABLE
or CREATE
TRIGGER
.
Note:
The instantiation SCN specified by this procedure is used only for LCRs captured by a capture process. It is not used for user-created LCRs.See Also:
"LCR$_ROW_RECORD Type" for more information about row LCRs
"LCR$_DDL_RECORD Type" for more information about DDL LCRs
This procedure adds, modifies, or removes a prebuilt update conflict handler for the specified object.
Syntax
DBMS_APPLY_ADM.SET_UPDATE_CONFLICT_HANDLER( object_name IN VARCHAR2, method_name IN VARCHAR2, resolution_column IN VARCHAR2, column_list IN DBMS_UTILITY.NAME_ARRAY, apply_database_link IN VARCHAR2 DEFAULT NULL);
Parameters
Table 20-25 SET_UPDATE_CONFLICT_HANDLER Procedure Parameters
Parameter | Description |
---|---|
|
The schema and name of the table, specified as For example, if an update conflict handler is being added for table |
|
Type of update conflict handler to create. You can specify one of the prebuilt handlers, which determine whether the column list from the source database is applied for the row or whether the values in the row at the destination database are retained:
If |
|
Name of the column used to uniquely identify an update conflict handler. For the
|
|
List of columns for which the conflict handler is called. The same column cannot be in more than one column list. If a conflict occurs for one or more of the columns in the list when an apply process tries to apply a row logical change record (row LCR), then the conflict handler is called to resolve the conflict. The conflict handler is not called if a conflict occurs only for columns that are not in the list. Note: Prebuilt update conflict handlers do not support LOB, |
|
The name of the database link to a non-Oracle database. This parameter should be set only when the destination database is a non-Oracle database. Note: Currently, conflict handlers are not supported when applying changes to a non-Oracle database. |
Usage Notes
If you want to modify an existing update conflict handler, then you specify the table and resolution column of an the existing update conflict handler. You can modify the prebuilt method or the column list.
If you want to remove an existing update conflict handler, then specify NULL
for the prebuilt method and specify the table, column list, and resolution column of the existing update conflict handler.
If an update conflict occurs, then Oracle completes the following series of actions:
Calls the appropriate update conflict handler to resolve the conflict
If no update conflict handler is specified or if the update conflict handler cannot resolve the conflict, then calls the appropriate error handler for the apply process, table, and operation to handle the error
If no error handler is specified or if the error handler cannot resolve the error, then raises an error and moves the transaction containing the row LCR that caused the error to the error queue
If you cannot use a prebuilt update conflict handler to meet your requirements, then you can create a PL/SQL procedure to use as a custom conflict handler. You use the SET_DML_HANDLER
procedure to designate one or more custom conflict handlers for a particular table. In addition, a custom conflict handler can process LOB columns and use LOB assembly.
Also, when a column is in a column list, and you try to add the same column to another column list, this procedure returns the following error:
ORA-00001: UNIQUE CONSTRAINT (SYS.APPLY$_CONF_HDLR_COLUMNS_UNQ1) VIOLATED
Note:
Setting an update conflict handler for an apply process that is applying to a non-Oracle database is not supported.See Also:
"Signature of an Error Handler Procedure" for information about setting an error handler
Oracle Streams Replication Administrator's Guide for more information about prebuilt and custom update conflict handlers
Examples
The following is an example for setting an update conflict handler for the employees
table in the hr
schema:
DECLARE cols DBMS_UTILITY.NAME_ARRAY; BEGIN cols(1) := 'salary'; cols(2) := 'commission_pct'; DBMS_APPLY_ADM.SET_UPDATE_CONFLICT_HANDLER( object_name => 'hr.employees', method_name => 'MAXIMUM', resolution_column => 'salary', column_list => cols); END; /
This example sets a conflict handler that is called if a conflict occurs for the salary
or commission_pct
column in the hr.employees
table. If such a conflict occurs, then the salary
column is evaluated to resolve the conflict. If a conflict occurs only for a column that is not in the column list, such as the job_id
column, then this conflict handler is not called.
This procedure sets or removes a value dependency. A value dependency is a virtual dependency definition that defines a relationship between the columns of two or more tables.
An apply process uses the name of a value dependencies to detect dependencies between row logical change records (row LCRs) that contain the columns defined in the value dependency. Value dependencies can define virtual foreign key relationships between tables, but, unlike foreign key relationships, value dependencies can involve more than two database objects.
This procedure is overloaded. The attribute_list
and attribute_table
parameters are mutually exclusive.
Syntax
DBMS_APPLY_ADM.SET_VALUE_DEPENDENCY( dependency_name IN VARCHAR2, object_name IN VARCHAR2, attribute_list IN VARCHAR2); DBMS_APPLY_ADM.SET_VALUE_DEPENDENCY( dependency_name IN VARCHAR2, object_name IN VARCHAR2, attribute_table IN DBMS_UTILITY.NAME_ARRAY);
Parameters
Table 20-26 SET_VALUE_DEPENDENCY Procedure Parameters
Parameter | Description |
---|---|
|
The name of the value dependency. If a dependency with the specified name does not exist, then it is created. If a dependency with the specified name exists, then the specified object and attributes are added to the dependency. If |
|
The name of the table, specified as If If |
|
A comma-delimited list of column names in the table. There must be no spaces between entries. |
|
A PL/SQL index-by table of type |
This procedure directs the apply process to start applying messages.
Syntax
DBMS_APPLY_ADM.START_APPLY( apply_name IN VARCHAR2);
Parameter
Table 20-27 START_APPLY Procedure Parameter
Parameter | Description |
---|---|
|
The apply process name. A |
Usage Notes
The apply process status is persistently recorded. Hence, if the status is ENABLED
, then the apply process is started upon database instance startup. An apply process (a
nnn
) is an Oracle background process. The enqueue and dequeue state of DBMS_AQADM.START_QUEUE
and DBMS_AQADM.STOP_QUEUE
have no effect on the start status of an apply process.
This procedure stops the apply process from applying messages and rolls back any unfinished transactions being applied.
Syntax
DBMS_APPLY_ADM.STOP_APPLY( apply_name IN VARCHAR2, force IN BOOLEAN DEFAULT FALSE);
Parameters
Table 20-28 STOP_APPLY Procedure Parameters
Parameter | Description |
---|---|
|
The apply process name. A |
|
If If The behavior of the apply process depends on the setting specified for the |
Usage Notes
The apply process status is persistently recorded. Hence, if the status is DISABLED
or ABORTED
, then the apply process is not started upon database instance startup.
The enqueue and dequeue state of DBMS_AQADM.START_QUEUE
and DBMS_AQADM.STOP_QUEUE
have no effect on the STOP
status of an apply process.
The following table describes apply process behavior for each setting of the force
parameter in the STOP_APPLY
procedure and the commit_serialization
apply process parameter. In all cases, the apply process rolls back any unfinished transactions when it stops.
force | commit_serialization | Apply Process Behavior |
---|---|---|
TRUE |
FULL |
The apply process stops immediately and does not apply any unfinished transactions. |
TRUE |
DEPENDENT_TRANSACTIONS |
When the apply process stops, some transactions that have been applied locally might have committed at the source database at a later point in time than some transactions that have not been applied locally. |
FALSE |
FULL |
The apply process stops after applying the next uncommitted transaction in the commit order, if any such transaction is in progress. |
FALSE |
DEPENDENT_TRANSACTIONS |
Before stopping, the apply process applies all of the transactions that have a commit time that is earlier than the applied transaction with the most recent commit time. |
For example, assume that the commit_serialization
apply process parameter is set to DEPENDENT_TRANSACTIONS
and there are three transactions: transaction 1 has the earliest commit time, transaction 2 is committed after transaction 1, and transaction 3 has the latest commit time. Also assume that an apply process has applied transaction 1 and transaction 3 and is in the process of applying transaction 2 when the STOP_APPLY
procedure is run. Given this scenario, if the force
parameter is set to TRUE
, then transaction 2 is not applied, and the apply process stops (transaction 2 is rolled back). If, however, the force
parameter is set to FALSE
, then transaction 2 is applied before the apply process stops.
A different scenario would result if the commit_serialization
apply process parameter is set to FULL
. For example, assume that the commit_serialization
apply process parameter is set to FULL
and there are three transactions: transaction A has the earliest commit time, transaction B is committed after transaction A, and transaction C has the latest commit time. In this case, the apply process has applied transaction A and is in the process of applying transactions B and C when the STOP_APPLY
procedure is run. Given this scenario, if the force
parameter is set to TRUE
, then transactions B and C are not applied, and the apply process stops (transactions B and C are rolled back). If, however, the force
parameter is set to FALSE
, then transaction B is applied before the apply process stops, and transaction C is rolled back.
See Also:
"SET_PARAMETER Procedure" for more information about thecommit_serialization
apply process parameter