| Oracle8i Replication API Reference Release 8.1.5 A67793-01 |
|
All installations of Oracle advanced replication include the replication management application programming interface (API). A server's replication management API is a set of PL/SQL packages that encapsulates procedures and functions that administrators can use to configure Oracle's advanced replication features. Oracle Replication Manager also uses the procedures and functions of each site's replication management API to perform work. This chapter describes that packages that constitute Oracle replication API, including:
Oracle's replication management API includes the following packages:
To use Oracle's replication management API, you issue procedure or function calls using an ad-hoc query tool such as an Enterprise Manager SQL Worksheet, Server Manager's command prompt, or SQL*Plus. For example, the following call to the DBMS_REPCAT.CREATE_MASTER_REPOBJECT procedure creates a new replicated table SALES.EMP in the ACCT replication group.
DBMS_REPCAT.CREATE_MASTER_REPOBJECT( sname => 'sales', oname => 'emp', type => 'table', use_existing_object => TRUE, ddl_text => 'CREATE TABLE acct_rec.emp AS . . .', comment => 'created by . . .', retry => FALSE, copy_rows => TRUE, gname => 'acct');
To call a replication management API function, you must provide an environment to receive the return value of the function. For example, the following anonymous PL/SQL block calls the DBMS_DEFER_SYS.DISABLED function in an IF statement.
BEGIN IF DBMS_DEFER_SYS.DISABLED('inst2') THEN DBMS_OUTPUT.PUT_LINE('Propagation to INST2 is disabled.'); ELSE DBMS_OUTPUT.PUT_LINE('Propagation to INST2 is enabled.'); END IF; END;
For many procedures and functions in the replication management API, there are important prerequisites to consider. For example:
Oracle's Replication Manager uses the replication management API to perform most of its functions. Using Replication Manager is much more convenient than issuing replication management API calls individually because the utility:
An easy way to learn how to use Oracle's replication management API is to use Replication Manager scripting feature. When you start an administrative session with Replication Manager, turn scripting on. When you are finished, turn scripting off and then review the script file. The script file contains all replication management API calls that were made during the session. See the Replication Manager help documentation for more information about its scripting feature.
| Subprogram | Description |
|---|---|
CALL procedure |
Builds a deferred call to a remote procedure |
COMMIT_WORK procedure |
Performs a transaction commit after checking for well-formed deferred remote procedure calls |
datatype_ARG procedure |
Provides the data that is to be passed to a deferred remote procedure call |
TRANSACTION procedure |
Indicates the start of a new deferred transaction |
This procedure builds a deferred call to a remote procedure.
DBMS_DEFER.CALL ( schema_name IN VARCHAR2, package_name IN VARCHAR2, proc_name IN VARCHAR2, arg_count IN NATURAL, { nodes IN node_list_t | group_name IN VARCHAR2 :=''});
This procedure performs a transaction commit after checking for well-formed deferred remote procedure calls.
DBMS_DEFER.COMMIT_WORK ( commit_work_comment IN VARCHAR2);
| Parameter | Description |
|---|---|
commit_work_ comment |
Equivalent to SQL "COMMIT COMMENT" statement. |
| Exception | Description |
|---|---|
ORA-23304 (malformedcall) |
Transaction was not correctly formed or terminated. |
This procedure provides the data that is to be passed to a deferred remote procedure call. Depending upon the type of the data that you need to pass to a procedure, you must call one of the following procedures for each argument to the procedure.
DBMS_DEFER.NUMBER_ARG (arg IN NUMBER); DBMS_DEFER.DATE_ARG (arg IN DATE); DBMS_DEFER.VARCHAR2_ARG (arg IN VARCHAR2); DBMS_DEFER.CHAR_ARG (arg IN CHAR); DBMS_DEFER.ROWID_ARG (arg IN ROWID); DBMS_DEFER.RAW_ARG (arg IN RAW); DBMS_DEFER.BLOB_ARG (arg IN BLOB); DBMS_DEFER.CLOB_ARG (arg IN CLOB); DBMS_DEFER.NCLOB_ARG (arg IN NCLOB); DBMS_DEFER.NCHAR_ARG (arg IN NCHAR); DBMS_DEFER.NVARCHAR2_ARG (arg IN NVARCHAR2); DBMS_DEFER.ANY_CLOB_ARG (arg IN CLOB); DBMS_DEFER.ANY_VARCHAR2_ARG (arg IN VARCHAR2); DBMS_DEFER.ANY_CHAR_ARG (arg IN CHAR);
| Parameter | Description |
|---|---|
arg |
Value of the parameter that you want to pass to the remote procedure to which you previously deferred a call. |
| Exception | Description |
|---|---|
ORA-23323 |
Argument value is too long. |
This procedure indicates the start of a new deferred transaction. If you omit this call, then Oracle considers your first call to DBMS_DEFER.CALL to be the start of a new transaction.
DBMS_DEFER.TRANSACTION ( nodes IN node_list_t);
The TRANSACTION procedure is overloaded. The behavior of the version without an input parameter is similar to that of the version with an input parameter, except that the former uses the nodes in the DEFDEFAULTDEST view instead of using the nodes in the nodes parameter.
| Subprogram | Description |
|---|---|
GET_ARG_FORM function |
Determines the form of an argument in a deferred call. |
GET_ARG_TYPE function |
Determines the type of an argument in a deferred call. |
GET_CALL_ARGS procedure |
Returns the text version of the various arguments for the given call. |
GET_datatype_ARG function |
Determines the value of an argument in a deferred call. |
This function determines the form of an argument in a deferred call. This function will return the character set ID of a deferred call parameter.
For more about displaying deferred transactions, see "Displaying Deferred Transactions" in the Oracle8i Replication manual. For more information about displaying error transactions, see "Displaying Error Transactions" in the Oracle8i Replication manual.
DBMS_DEFER_QUERY.GET_ARG_FORM ( callno IN NUMBER, arg_no IN NUMBER, deferred_tran_id IN VARCHAR2) RETURN NUMBER;
| Exception | Description |
|---|---|
NO_DATA_FOUND |
Input parameters do not correspond to a parameter of a deferred call. |
| Return Value | Corresponding Datatype |
|---|---|
1 |
CHAR, VARCHAR2, CLOB |
2 |
NCHAR, NVARCHAR2, NCLOB |
This function determines the type of an argument in a deferred call. The type of the deferred RPC parameter will be returned.
For more about displaying deferred transactions, see "Displaying Deferred Transactions" in the Oracle8i Replication manual. For more information about displaying error transactions, see "Displaying Error Transactions" in the Oracle8i Replication manual.
DBMS_DEFER_QUERY.GET_ARG_TYPE ( callno IN NUMBER, arg_no IN NUMBER, deferred_tran_id IN VARCHAR2) RETURN NUMBER;
| Exception | Description |
|---|---|
NO_DATA_FOUND |
Input parameters do not correspond to a parameter of a deferred call. |
| Return Value | Corresponding Datatype |
|---|---|
1 |
VARCHAR2 |
2 |
NUMBER |
11 |
ROWID |
12 |
DATE |
23 |
RAW |
96 |
CHAR |
112 |
CLOB |
113 |
BLOB |
This procedure returns the text version of the various arguments for the given call. The text version is limited to the first 2000 bytes.
DBMS_DEFER_QUERY.GET_CALL_ARGS ( callno IN NUMBER, startarg IN NUMBER := 1, argcnt IN NUMBER, argsize IN NUMBER, tran_id IN VARCHAR2, date_fmt IN VARCHAR2, types OUT TYPE_ARY, forms OUT TYPE_ARY, vals OUT VAL_ARY);
| Exception | Description |
|---|---|
NO_DATA_FOUND |
Input parameters do not correspond to a parameter of a deferred call. |
This function determines the value of an argument in a deferred call.
For more about displaying deferred transactions, see "Displaying Deferred Transactions" in the Oracle8i Replication manual. For more information about displaying error transactions, see "Displaying Error Transactions" in the Oracle8i Replication manual.
Depending upon the type of the argument value that you want to retrieve, the syntax for the appropriate function is as follows. Each of these functions returns the value of the specified argument.
DBMS_DEFER_QUERY.GET_datatype_ARG ( callno IN NUMBER, arg_no IN NUMBER, deferred_tran_id IN VARCHAR2 DEFAULT NULL) RETURN datatype;
where datatype:
{ NUMBER | VARCHAR2 | CHAR | DATE | RAW | ROWID | BLOB | CLOB | NCLOB | NCHAR | NVARCHAR2 }
| Exception | Description |
|---|---|
NO_DATA_FOUND |
Input parameters do not correspond to a parameter of a deferred call. |
ORA-26564 |
Argument in this position is not of the specified type. |
| Subprogram | Description |
|---|---|
ADD_DEFAULT_DEST procedure |
Adds a destination database to the |
DELETE_DEFAULT_DEST procedure |
Removes a destination database from the |
DELETE_DEF_DESTINATION procedure |
Removes a destination database from the |
DELETE_ERROR |
Deletes a transaction from the |
DELETE_TRAN |
Deletes a transaction from the |
DISABLED |
Determines whether propagation of the deferred transaction queue from the current site to a given site is enabled. |
EXCLUDE_PUSH |
Acquires an exclusive lock that prevents deferred transaction |
EXECUTE_ERROR |
Re-executes a deferred transaction that did not initially complete successfully. |
EXECUTE_ERROR_AS_USER |
Re-executes a deferred transaction that did not initially complete successfully. |
PURGE |
Purges pushed transactions from the deferred transaction queue at your current master or snapshot site. |
PUSH function |
Forces a deferred remote procedure call queue at your current master or snapshot site to be pushed to another master site. |
REGISTER_PROPAGATOR procedure |
Registers the given user as the propagator for the local database. |
SCHEDULE_PURGE procedure |
Schedules a job to purge pushed transactions from the deferred transaction queue at your current master or snapshot site. |
SCHEDULE_PUSH procedure |
Schedules a job to push the deferred transaction queue to a remote master destination. |
SET_DISABLED procedure |
Disables or enables propagation of the deferred transaction queue from the current site to a given destination site. |
UNREGISTER_PROPAGATOR procedure |
Unregister a user as the propagator from the local database. |
UNSCHEDULE_PURGE procedure |
Stops automatic purges of pushed transactions from the deferred transaction queue at a snapshot or master site. |
UNSCHEDULE_PUSH procedure |
Stops automatic pushes of the deferred transaction queue from a snapshot or master site to another master site. |
This procedure adds a destination database to the DEFDEFAULTDEST view.
DBMS_DEFER_SYS.ADD_DEFAULT_DEST ( dblink IN VARCHAR2);
| Parameter | Description |
|---|---|
dblink |
The fully qualified database name of the node that you want to add to the |
| Exception | Description |
|---|---|
ORA-23352 |
The |
This procedure removes a destination database from the DEFDEFAULTDEST view.
DBMS_DEFER_SYS.DELETE_DEFAULT_DEST ( dblink IN VARCHAR2);
This procedure removes a destination database from the DEFSCHEDULE view.
DBMS_DEFER_SYS.DELETE_DEF_DESTINATION ( destination IN VARCHAR2, force IN BOOLEAN := FALSE);
To delete a transaction from the DEFERROR view.
DBMS_DEFER_SYS.DELETE_ERROR( deferred_tran_id IN VARCHAR2, destination IN VARCHAR2);
To delete a transaction from the DEFTRANDEST view. If there are no other DEFTRANDEST or DEFERROR entries for the transaction, then the transaction is deleted from the DEFTRAN and DEFCALL views as well.
DBMS_DEFER_SYS.DELETE_TRAN ( deferred_tran_id IN VARCHAR2, destination IN VARCHAR2);
To determine whether propagation of the deferred transaction queue from the current site to a given site is enabled. The DISABLED function returns TRUE if the deferred remote procedure call (RPC) queue is disabled for the given destination.
DBMS_DEFER_SYS.DISABLED ( destination IN VARCHAR2) RETURN BOOLEAN;
| Parameter | Description |
|---|---|
destination |
The fully qualified database name of the node whose propagation status you want to check. |
| Value | Description |
|---|---|
TRUE |
Propagation to this site from the current site is disabled. |
FALSE |
Propagation to this site from the current site is enabled. |
| Exception | Description |
|---|---|
NO_DATA_FOUND |
|
To acquire an exclusive lock that prevents deferred transaction PUSH (either serial or parallel). This function does a commit when acquiring the lock. The lock is acquired with RELEASE_ON_COMMIT => TRUE, so that pushing of the deferred transaction queue can resume after the next commit.
DBMS_DEFER_SYS.EXCLUDE_PUSH ( timeout IN INTEGER) RETURN INTEGER;
| Value | Description |
|---|---|
0 |
Success, lock acquired. |
1 |
Timeout, no lock acquired. |
2 |
Deadlock, no lock acquired. |
4 |
Already own lock. |
To reexecute a deferred transaction that did not initially complete successfully. This procedure raises an ORA-24275 error when illegal combinations of NULL and non-NULL parameters are used.
DBMS_DEFER_SYS.EXECUTE_ERROR ( deferred_tran_id IN VARCHAR2, destination IN VARCHAR2);
| Exception | Description |
|---|---|
badparam |
Parameter value missing or invalid (for example, if |
missinguser |
Invalid user. |
To reexecute a deferred transaction that did not initially complete successfully. Each transaction is executed in the security context of the connected user. This procedure raises an ORA-24275 error when illegal combinations of NULL and non-NULL parameters are used.
DBMS_DEFER_SYS.EXECUTE_ERROR_AS_USER ( deferred_tran_id IN VARCHAR2, destination IN VARCHAR2);
| Exception | Description |
|---|---|
badparam |
Parameter value missing or invalid (for example, if destination is |
missinguser |
Invalid user. |
To purge pushed transactions from the deferred transaction queue at your current master or snapshot site.
DBMS_DEFER_SYS.PURGE ( purge_method IN BINARY_INTEGER := purge_method_quick, rollback_segment IN VARCHAR2 := NULL, startup_seconds IN BINARY_INTEGER := 0, execution_seconds IN BINARY_INTEGER := seconds_infinity, delay_seconds IN BINARY_INTEGER := 0, transaction_count IN BINARY_INTEGER := transactions_infinity, write_trace IN BOOLEAN := NULL); RETURN BINARY_INTEGER;
| Exception | Description |
|---|---|
argoutofrange |
Parameter value is out of a valid range. |
executiondisabled |
Execution of purging is disabled. |
defererror |
Internal error. |
This function forces a deferred remote procedure call queue at your current master or snapshot site to be pushed (executed, propagated) to another master site using either serial or parallel propagation.
DBMS_DEFER_SYS.PUSH ( destination IN VARCHAR2, parallelism IN BINARY_INTEGER := 0, heap_size IN BINARY_INTEGER := 0) stop_on_error IN BOOLEAN := FALSE, write_trace IN BOOLEAN := FALSE, startup_seconds IN BINARY_INTEGER := 0, execution_seconds IN BINARY_INTEGER := seconds_infinity, delay_seconds IN BINARY_INTEGER := 0, transaction_count IN BINARY_INTEGER := transactions_infinity, delivery_order_limit IN NUMBER := delivery_order_infinity) RETURN BINARY_INTEGER;
This procedure registers the given user as the propagator for the local database. It also grants to the given user CREATE SESSION, CREATE PROCEDURE, CREATE DATABASE LINK, and EXECUTE ANY PROCEDURE privileges (so that the user can create wrappers).
DBMS_DEFER_SYS.REGISTER_PROPAGATOR ( username IN VARCHAR2);
| Parameter | Description |
|---|---|
username |
Name of the user. |
| Exception | Description |
|---|---|
missinguser |
Given user does not exist. |
alreadypropagator |
Given user is already the propagator. |
duplicatepropagator |
There is already a different propagator. |
This procedure schedules a job to purge pushed transactions from the deferred transaction queue at your current master or snapshot site. You should schedule one purge job.
DBMS_DEFER_SYS.SCHEDULE_PURGE ( interval IN VARCHAR2, next_date IN DATE, reset IN BOOLEAN := NULL, purge_method IN BINARY_INTEGER := NULL, rollback_segment IN VARCHAR2 := NULL, startup_seconds IN BINARY_INTEGER := NULL, execution_seconds IN BINARY_INTEGER := NULL, delay_seconds IN BINARY_INTEGER := NULL, transaction_count IN BINARY_INTEGER := NULL, write_trace IN BOOLEAN := NULL);