PL/SQL Packages and Types Reference 10g Release 1 (10.1) Part Number B10802-01 |
|
|
View PDF |
The DBMS_CDC_SUBSCRIBE
package lets subscribers view and query change data that was captured and published with the DBMS_CDC_PUBLISH
package.
A Change Data Capture system usually has one publisher and many subscribers. The subscribers (applications or individuals), use the Oracle supplied package, DBMS_CDC_SUBSCRIBE
, to access published data.
Be aware that Change Data Capture grants EXECUTE
privileges to PUBLIC
on the DBMS_CDC_SUBSCRIBE
procedure.
See Also:
Oracle Data Warehousing Guide for more information about Oracle Change Data Capture and DBMS_CDC_PUBLISH for information on the package for publishing change data. |
This chapter contains the following topics:
The primary role of the subscriber is to use the change data. Through the DBMS_CDC_SUBSCRIBE
package, each subscriber registers interest in a set of source tables by subscribing to them.
Once the publisher sets up the system to capture data into change tables (which are viewed as publications by subscribers) and grants subscribers access to the change tables, subscribers can access and query the published change data for any of the source tables of interest. Using the procedures in the DBMS_CDC_SUBSCRIBE
package, the subscriber accomplishes the following main objectives:
SELECT
statements to retrieve change data from the subscriber viewsFigure 21-1 provides a graphical flowchart of the information provided in Table 21-1. The flowchart shows the order in which subscribers most typically use the procedures in the DBMS_CDC_SUBSCRIBE
package. A subscriber would typically create a subscription, subscribe to one or more source tables and columns, activate the subscription, extend the subscription window, query the subscriber views, purge the subscription window, and then either extend the subscription window again or drop the subscription.
Note: If a subscriber uses the |
Text description of the illustration arpls011.gif
The following DBMS_CDC_SUBSCRIBE
procedures have been deprecated beginning with release 10g:
GET_SUBSCRIPTION_HANDLE
Subscribers no longer explicitly specify subscription handles. Subscribers should use the CREATE_SUBSCRIPTION
procedure instead to specify a subscription name.
PREPARE_SUBSCRIBER_VIEW
Subscribers no longer need to prepare subscriber views. This work is now done automatically by Change Data Capture.
DROP_SUBSCRIBER_VIEW
Subscribers no longer need to drop subscriber views. This work is now done automatically by Change Data Capture.
If an existing application uses these deprecated DBMS_CDC_SUBSCRIBE
procedures with release 10g, note the following changes in behavior:
DBMS_CDC_SUBSCRIBE.EXTEND_WINDOW
to see the new column structure.
In addition, the use of the subscription_handle
parameter with the following DBMS_CDC_SUBSCRIBE
procedures has been deprecated beginning with release 10g:
This procedure indicates that a subscription is ready to start accessing change data.
DBMS_CDC_SUBSCRIBE.ACTIVATE_SUBSCRIPTION( subscription_name IN VARCHAR2);
ACTIVATE_SUBSCRIPTION
procedure indicates that the subscriber is finished subscribing to tables, and the subscription is ready to start accessing change data.EXTEND_WINDOW
procedure to see the initial set of change data.end_date
parameter value.This procedure creates a subscription that is associated with one change set. This procedure replaces the deprecated GET_SUBSCRIPTION_HANDLE
procedure.
DBMS_CDC_SUBSCRIBE.CREATE_SUBSCRIPTION( change_set_name IN VARCHAR2, description IN VARCHAR2, subscription_name IN VARCHAR2);
The
CREATE_SUBSCRIPTION
procedure allows a subscriber to register interest in a change set associated with source tables of interest.ALL_PUBLISHED_COLUMNS
view to see all the published source tables for which the subscriber has privileges and the change sets in which the source table columns are published.end_date
parameter value.This procedure drops a subscription.
DBMS_CDC_SUBSCRIBE.DROP_SUBSCRIPTION( subscription_name IN VARCHAR2);
Exception | Description |
---|---|
|
One or more values for input parameters are incorrect |
|
Subscription does not exist |
Subscribers should be diligent about dropping subscriptions that are no longer needed so that change data will not be held in the change tables unnecessarily.
This procedure sets the subscription window high boundary so that new change data can be seen.
DBMS_CDC_SUBSCRIBE.EXTEND_WINDOW( subscription_name IN VARCHAR2);
EXTEND_WINDOW
procedure to begin receiving change data, the subscription window remains empty.
DBMS_CDC_SUBSCRIBE
package and access data through subscriber views only. Control column values are guaranteed to be consistent only when viewed through subscriber views that have been updated with a call to the EXTEND_WINDOW
procedure.end_date
parameter value, subsequent calls to the EXTEND_WINDOW
procedure will not raise the high boundary.This procedure sets the low boundary of the subscription window so that the subscription no longer sees any change data, effectively making the subscription window empty. The subscriber calls this procedure to notify Change Data Capture that the subscriber is finished processing a block of change data.
DBMS_CDC_SUBSCRIBE.PURGE_WINDOW( subscription_name IN VARCHAR2);
PURGE_WINDOW
procedure. By this action, the subscriber performs the following functions:
Change Data Capture manages the change data to ensure that it is available as long as there are subscribers who need it.
end_date
parameter value, subsequent calls to the PURGE_WINDOW
procedure will not move the low boundary.This procedure specifies a source table and the source columns for which the subscriber wants to access change data. In addition, it specifies the subscriber view through which the subscriber sees change data for the source table.
There are two versions of syntax for the SUBSCRIBE
procedure, as follow:
When this syntax is used, Change Data Capture will attempt to find a single publication ID that contains the specified source_table
and column_list
. If such a publication cannot be found, then Change Data Capture returns an error.
DBMS_CDC_SUBSCRIBE.SUBSCRIBE( subscription_name IN VARCHAR2, source_schema IN VARCHAR2, source_table IN VARCHAR2, column_list IN VARCHAR2, subscriber_view IN VARCHAR2);
When this syntax is used, Change Data Capture will use the publication ID to identify the change table. If the columns specified in the column_list
parameter are not in the identified change table, then Change Data Capture returns an error.
DBMS_CDC_SUBSCRIBE.SUBSCRIBE( subscription_name IN VARCHAR2, publication_id IN NUMBER, column_list IN VARCHAR2, subscriber_view IN VARCHAR2);
SUBSCRIBE
procedure allows a subscriber to subscribe to one or more published source tables and to specific columns in each source table. Each call to the SUBSCRIBE
procedure can specify only a single source table or publication ID. The subscriber can make multiple calls to the SUBSCRIBE
procedure to include multiple source tables or publications IDs in a subscription.SUBSCRIBE
procedure using the source_schema
and source_table
parameters or using the publication_id
parameter. However, if there are multiple publications on a single source table and these publications share some columns, and if any of the shared columns will be used by a single subscription, then the subscriber should call the SUBSCRIBE
procedure using the publication_id
parameter.ALL_PUBLISHED_COLUMNS
view.ALL_PUBLISHED_COLUMNS
view to see all the published source table columns accessible to the subscriber.SUBSCRIBE
procedure. Change Data Capture does not guarantee that there will be any change data available at the moment the subscription is created.SUBSCRIBE
procedure must come from the same publication. Any control columns associated with the underlying change table are added to the subscription automatically.