PL/SQL Packages and Types Reference 10g Release 1 (10.1) Part Number B10802-01 |
|
|
View PDF |
The DBMS_CDC_PUBLISH
package is used by a publisher to set up an Oracle Change Data Capture system to capture and publish change data from one or more Oracle relational source tables.
Change Data Capture captures and publishes only committed data. Oracle Change Data Capture identifies new data that has been added to, updated in, or removed from relational tables, and publishes the change data in a form that is usable by subscribers.
Typically, a Change Data Capture system has one publisher who captures and publishes changes for any number of Oracle relational source tables. The publisher then provides subscribers (applications or individuals) with access to the published data.
See Also:
Oracle Data Warehousing Guide for more information about Oracle Change Data Capture and DBMS_CDC_SUBSCRIBE for information on the package used to subscribe to published change data |
This chapter contains the following topics:
Through the DBMS_CDC_PUBLISH
package, the publisher creates and maintains change sources, change sets, and change tables, and eventually drops them when they are no longer useful.
The publisher, typically a database administrator, is concerned primarily with the source of the data and with creating the schema objects that describe the structure of the capture system: change sources, change sets, and change tables.
Most Change Data Capture systems have one publisher and many subscribers. The publisher accomplishes the following main objectives:
DBMS_CDC_PUBLISH
package to capture change data from the source tables and make it available by creating and administering the change source, change set, and change table objects.GRANT
and REVOKE
statements to grant and revoke the SELECT
privilege on change tables for users and roles. (This is necessary to allow the subscribers to subscribe to the change data using the DBMS_CDC_SUBSCRIBE
package.)To use the DBMS_CDC_PUBLISH
package, the publisher must have the EXECUTE_CATALOG_ROLE
privilege.
The following subprograms have been deprecated beginning with release 10g:
DBMS_CDC_PUBLISH.DROP_SUBSCRIBER_VIEW
Dropping a subscriber view is now performed automatically by Change Data Capture.
DBMS_CDC_PUBLISH.DROP_SUBSCRIPTION
with a subscription handle
When dropping a subscription, the publisher should now specify the name of the subscription to be dropped, not the subscription handle.
Table 20-1 describes the subprograms in the DBMS_CDC_PUBLISH
supplied package and the mode or modes with which each can be used. A value of All in Mode column of Table 20-1 indicates that the subprogram can be used with synchronous and both modes of asynchronous Change Data Capture.
This procedure changes the properties of an existing AutoLog change source.
DBMS_CDC_PUBLISH.ALTER_AUTOLOG_CHANGE_SOURCE( change_source_name IN VARCHAR2, description IN VARCHAR2 DEFAULT NULL, remove_description IN VARCHAR2 DEFAULT 'N', first_scn IN NUMBER DEFAULT NULL);
This procedure changes the properties of an existing change set that was created with the CREATE_CHANGE_SET
procedure.
DBMS_CDC_PUBLISH.ALTER_CHANGE_SET( change_set_name IN VARCHAR2, description IN VARCHAR2 DEFAULT NULL, remove_description IN CHAR DEFAULT 'N', enable_capture IN CHAR DEFAULT NULL, recover_after_error IN CHAR DEFAULT NULL, remove_ddl IN CHAR DEFAULT NULL, stop_on_ddl IN CHAR DEFAULT NULL);
SYNC_SET
, cannot be altered, and the following parameters cannot be altered for publisher-defined synchronous change sets: enable_capture
, recover_after_error
, remove_ddl
, and stop_on_ddl
.stop_on_ddl
parameter is as follows:
stop_on_ddl
parameter is set to 'Y', asynchronous Change Data Capture stops if DDL is encountered during change data capture. Some DDL statements can adversely affect capture, such as a statement that drops a source table column that is being captured. The publisher has an opportunity to analyze and adjust to DDL changes that may adversely affect change tables while capture is stopped, thereby preventing possible errors during capture.
Because these statements do not affect the column data itself, Change Data Capture does not stop capturing change data when the stop_on_ddl
parameter is set to 'Y' and any of the following statements is encountered:
ANALYZE TABLE
LOCK TABLE
GRANT
privileges to access a tableREVOKE
privileges to access a tableCOMMENT
on a tableCOMMENT
on a columnThese statements can be issued on the source database without concern for their impact on Change Data Capture processing.
stop_on_ddl
parameter is set to 'N', Change Data Capture does not stop if DDL is encountered during change data capture. If a change set does not stop on DDL, but a DDL change occurs that affects change tables, that change can result in a capture error. (There are also system conditions that can cause capture errors, such as being out of disk space.)
See Also:
The Change Data Capture chapter in Oracle Data Warehousing Guide for information on the effects of, and how to recover from, a capture error |
Whenever a DDL statement causes processing to stop, a message is written to the alert log indicating for which change set processing has been stopped and the DDL statement that caused it to be stopped. Similarly, whenever DDL statements are ignored by Change Data Capture and processing continues, a message is written to the alert log indicating which DDL statement was ignored.
recover_after_error
parameter. Capture errors can occur when any of the following is true:
stop_on_ddl
parameter is set to 'Y' and there is a DDL record in the change data. In this case, to recover from the error, the publisher must also specify 'Y' for the remove_ddl
parameter.stop_on_ddl
parameter is set to 'N' and there is a DDL record that affects capture. For example, if the publisher drops and re-creates a change table, it causes an error the next time that Change Data Capture attempts to add change data to the named change table.See Also:
The Change Data Capture chapter in Oracle Data Warehousing Guide for more information on how to recover from a capture error |
This procedure adds columns to, or drops columns from, or changes the properties of, a change table that was created with the CREATE_CHANGE_TABLE
procedure.
DBMS_CDC_PUBLISH.ALTER_CHANGE_TABLE( owner IN VARCHAR2, change_table_name IN VARCHAR2, operation IN VARCHAR2, column_list IN VARCHAR2, rs_id IN CHAR, row_id IN CHAR, user_id IN CHAR, timestamp IN CHAR, object_id IN CHAR, source_colmap IN CHAR, target_colmap IN CHAR);
See Also:
The Change Data Capture chapter in Oracle Data Warehousing Guide for a complete description of control columns |
ALTER_CHANGE_TABLE
procedure; these schema changes require separate calls.column_ list
parameter.N
' for the source_colmap
and object_id
parameters.
See Also:
Oracle Data Warehousing Guide for information about the impact on subscriptions when a publisher adds a column to a change table |
This procedure creates an AutoLog change source. An AutoLog change source is based on of a set of redo log files automatically copied by log transport services to the system on which the staging database resides.
DBMS_CDC_PUBLISH.CREATE_AUTOLOG_CHANGE_SOURCE( change_source_name IN VARCHAR2, description IN VARCHAR2 DEFAULT NULL, source_database IN VARCHAR2, first_scn IN NUMBER);
source_database
parameter. Change Data Capture does not validate this value when creating the change source. The publisher can query the GLOBAL_NAME
column in the GLOBAL_NAME
view at the source database for the source_database
parameter value.See Also:
The section on performing asynchronous AutoLog publishing in Oracle Data Warehousing Guide for information on configuring log transport services to automatically copy the log files to the system on which the staging database resides |
CREATE_AUTOLOG_CHANGE_SOURCE
first_scn
parameter indicates the SCN for this dictionary extraction and is the point at which the change source can begin capturing changes. The publisher can determine the value for the first_scn
parameter using either of the following methods:
DBMS_CAPTURE_ADM.BUILD
to return the value when the dictionary is built:
SET SERVEROUTPUT ON VARIABLE FSCN NUMBER; BEGIN :FSCN := 0; DBMS_CAPTURE_ADM.BUILD(:FSCN); DBMS_OUTPUT.PUT_LINE('The first_scn value is ' || :FSCN); END; / The first_scn value is 207722
first_change#
, then the data dictionary has been extracted more than once and the publisher should choose the first_change#
value that is the most appropriate to the change source.
SELECT DISTINCT FIRST_CHANGE#, NAME FROM V$ARCHIVED_LOG WHERE DICTIONARY_BEGIN = 'YES';
See Also:
The Change Data Capture chapter in Oracle Data Warehousing Guide for information about supplemental logging |
This procedure allows the publisher to create a change set. For asynchronous Change Data Capture, the publisher can optionally provide beginning and ending date values at which to begin and end change data capture.
DBMS_CDC_PUBLISH.CREATE_CHANGE_SET( change_set_name IN VARCHAR2, description IN VARCHAR2 DEFAULT NULL, change_source_name IN VARCHAR2, stop_on_ddl IN CHAR DEFAULT 'N', begin_date IN DATE DEFAULT NULL, end_date IN DATE DEFAULT NULL);
begin_date
, end_date
, and stop_on_ddl
.begin_date
and end_date
parameters are optional. The publisher can specify neither of them, one of them, or both. The effect of these parameters is as follows:
begin_date
is specified, changes from transactions that begin on or after that date are captured.begin_date
is not specified, capture starts with the earliest available change data.end_date
is specified, changes from transactions that are committed on or before that date are captured.end_date
is not specified, Change Data Capture continues indefinitely.stop_on_ddl
parameter is as follows:
stop_on_ddl
parameter is set to 'Y', asynchronous Change Data Capture stops if DDL is encountered during change data capture. Some DDL statements can adversely affect capture, such as a statement that drops a source table column that is being captured. The publisher has an opportunity to analyze and adjust to DDL changes that may adversely affect change tables while capture is stopped, thereby preventing possible errors during capture.
Because these statements do not affect the column data itself, Change Data Capture does not stop capturing change data when the stop_on_ddl
parameter is set to 'Y' and any of the following statements is encountered:
ANALYZE TABLE
LOCK TABLE
GRANT
privileges to access a tableREVOKE
privileges to access a tableCOMMENT
on a tableCOMMENT
on a columnThese statements can be issued on the source database without concern for their impact on Change Data Capture processing.
stop_on_ddl
parameter is set to 'N', Change Data Capture does not stop if DDL is encountered during change data capture. If a change set does not stop on DDL, but a DDL change occurs that affects capture, that change can result in a capture error.
See Also:
The Change Data Capture chapter in Oracle Data Warehousing Guide for information on the effects of, and how to recover from, a capture error |
Whenever a DDL statement causes processing to stop, a message is written to the alert log indicating for which change set processing has been terminated and the DDL statement that caused it to be terminated. Similarly, whenever DDL statements are ignored by Change Data Capture and processing continues, a message is written to the alert log indicating which DDL statement was ignored.
This procedure creates a change table in a specified schema.
DBMS_CDC_PUBLISH.CREATE_CHANGE_TABLE( owner IN VARCHAR2, change_table_name IN VARCHAR2, change_set_name IN VARCHAR2, source_schema IN VARCHAR2, source_table IN VARCHAR2, column_type_list IN VARCHAR2, capture_values IN VARCHAR2, rs_id IN CHAR, row_id IN CHAR, user_id IN CHAR, timestamp IN CHAR, object_id IN CHAR, source_colmap IN CHAR, target_colmap IN CHAR, options_string IN VARCHAR2);
See Also:
The Change Data Capture chapter in Oracle Data Warehousing Guide for a complete description of control columns |
INSERT
, UPDATE,
and DELETE
) made to a source table. A given change table can capture changes from only one source table.N
' for the source_colmap
and object_id
parameters.rs_id
parameter, the RSID$
column is added to the change table. The RSID$
column value reflects an operation's capture order within a transaction, but not across transactions. The publisher cannot use the RSID$
column value by itself to order committed operations across transactions; it must be used in conjunction with the CSCN$
column value.options_string
parameter. With the options_string
parameter, the publisher can set any option that is valid for the CREATE TABLE
DDL statement (except for partitioning properties).
options_string
parameter. If a tablespace is not specified by the publisher, and the publisher's default table space is the system tablespace, then Change Data Capture creates change tables in the system tablespace.
See Also:
The Change Data Capture chapter inOracle Data Warehousing Guide for more information on, and examples of, creating change tables in tablespaces managed by the publisher |
This procedure drops an existing change set that was created with the CREATE_CHANGE_SET
procedure.
DBMS_CDC_PUBLISH.DROP_CHANGE_SET( change_set_name IN VARCHAR2);
Parameter | Description |
---|---|
|
Name of the change set to be dropped. Change set names follow the Oracle schema object naming rules. |
SYNC_SET
, cannot be dropped.This procedure drops an existing AutoLog change source that was created with the CREATE_AUTOLOG_CHANGE_SOURCE
procedure.
DBMS_CDC_PUBLISH.DROP_CHANGE_SOURCE( change_source_name IN VARCHAR2);
Parameter | Description |
---|---|
|
Name of the change source to be dropped. Change source names follow the Oracle schema object naming rules. |
HOTLOG_SOURCE
and SYNC_SOURCE,
cannot be dropped.This procedure drops an existing change table that was created with the CREATE_CHANGE_TABLE
procedure.
DBMS_CDC_PUBLISH.DROP_CHANGE_TABLE( owner IN VARCHAR2, change_table_name IN VARCHAR2, force_flag IN CHAR);
Exception | Description |
---|---|
|
Change table does not exist |
|
Specified owner schema does not exist |
|
Change table has active subscriptions |
|
Table is not a change table |
DROP_CHANGE_TABLE
procedure using the force_flag => 'Y'
parameter. This tells Change Data Capture to override its normal safeguards and allow the change table to be dropped despite active subscriptions. The subscriptions that include the dropped table will no longer be valid, and subscribers will lose access to the change data.This procedure allows a publisher to drop a subscription that was created by a subscriber with a prior call to the DBMS_CDC_SUBSCRIBE.CREATE_SUBSCRIPTION
procedure.
DBMS_CDC_PUBLISH.DROP_SUBSCRIPTION( subscription_name IN VARCHAR2);
Exception | Description |
---|---|
|
One or more values for input parameters are incorrect |
|
Subscription does not exist |
|
Invalid source table |
DBMS_CDC_SUBSCRIBE.DROP_SUBSCRIPTION
procedure.DBMS_CDC_SUBSCRIBE.DROP_SUBSCRIPTION
procedure and the publisher need not use the DBMS_CDC_SUBSCRIBE.DROP_SUBSCRIPTION
procedure.)This procedure monitors change table usage by all subscriptions, determines which rows are no longer needed by any subscriptions, and removes the unneeded rows to prevent change tables from growing indefinitely. When called, this procedure purges all change tables on the staging database.
DBMS_CDC_PUBLISH.PURGE;
Only standard Oracle exceptions (for example, a privilege violation) are returned during a purge operation.
DBMS_CDC_PUBLISH.PURGE
procedure (used by the publisher and the Change Data Capture default purge job) is distinct from the DBMS_CDC_SUBSCRIBE.PURGE_WINDOW
procedure (used by subscribers). A call to the DBMS_CDC_PUBLISH.PURGE
procedure physically removes unneeded rows from change tables. A call to the DBMS_CDC_SUBSCRIBE.PURGE_WINDOW
procedure, logically removes change rows from a subscription window, but does not physically remove rows from the underlying change tables.This procedure removes unneeded rows from all change tables in the named change set. This procedure allows a finer granularity purge operation than the basic PURGE
procedure.
DBMS_CDC_PUBLISH.PURGE_CHANGE_SET( change_set_name in VARCHAR2);
Parameter | Description |
---|---|
|
Name of an existing change set. Change set names follow the Oracle schema object naming rules. |
Exception | Description |
---|---|
|
Change set is not an existing change set |
DBMS_CDC_PUBLISH.PURGE_CHANGE_SET
procedure (used by the publisher) is distinct from the DBMS_CDC_SUBSCRIBE.PURGE_WINDOW
procedure (used by subscribers). A call to the DBMS_CDC_PUBLISH.PURGE_CHANGE_SET
procedure physically removes unneeded rows from change tables in the specified change set. A call to the DBMS_CDC_SUBSCRIBE.PURGE_WINDOW
procedure, logically removes change rows from a subscription window, but does not physically remove rows from the underlying change tables.This procedure removes unneeded rows from the named change table. This procedure allows a finer granularity purge operation than the basic PURGE
procedure or the PURGE_CHANGE_SET
procedure.
DBMS_CDC_PUBLISH.PURGE_CHANGE_TABLE( owner in VARCHAR2, change_table_name in VARCHAR2);
Parameter | Description |
---|---|
|
Owner of the named change table. |
|
Name of an existing change table. Change table names follow the Oracle schema object naming rules. |
Exception | Description |
---|---|
|
Change table does not exist |
DBMS_CDC_PUBLISH.PURGE_CHANGE_TABLE
procedure (used by the publisher) is distinct from the DBMS_CDC_SUBSCRIBE.PURGE_WINDOW
procedure (used by subscribers). A call to the DBMS_CDC_PUBLISH.PURGE_CHANGE_TABLE
procedure physically removes unneeded rows from the specified change table. A call to the DBMS_CDC_SUBSCRIBE.PURGE_WINDOW
procedure, logically removes change rows from a subscription window, but does not physically remove rows from the underlying change tables.