| Oracle9i Supplied PL/SQL Packages and Types Reference Release 2 (9.2) Part Number A96612-01 | 
 | 
DBMS_LOGMNR_CDC_SUBSCRIBE, 2 of 2
The primary role of the subscriber is to use the change data. Through the DBMS_LOGMNR_CDC_SUBSCRIBE package, each subscriber registers interest in a set of source tables by subscribing to them.
Table 27-1 describes the procedures for the DBMS_LOGMNR_CDC_SUBSCRIBE package.
Subscribers call the procedures in the order shown in Table 27-1 unless an error occurs, at which time the subscribers should exit. Figure 27-1 shows the most common steps for using the procedures in the DBMS_LOGMNR_CDC_SUBSCRIBE package.

In Figure 27-1:
PURGE_WINDOW procedure immediately after using an EXTEND_WINDOW procedure, then change data is lost without ever being processed.EXTEND_WINDOW procedure immediately after using the DROP_SUBSCRIBER_VIEW procedure, you will see the data that you just processed again and possibly some new data.DBMS_LOGMNR_CDC_SUBSCRIBE procedures should detect the error and exit. For example, if the PREPARE_SUBSCRIBER_VIEW procedure fails for any reason, and the application ignores the error and continues, then the PURGE_WINDOW procedure will delete data that was never seen or selected by the subscriber.This procedure creates a subscription handle that associates the subscription with one change set. Creating a subscription handle is the first step in obtaining a subscription.
DBMS_LOGMNR_CDC_SUBSCRIBE.GET_SUBSCRIPTION_HANDLE( change_set IN VARCHAR2, description IN VARCHAR2 := NULL, subscription_handle OUT NUMBER);
The GET_SUBSCRIPTION_HANDLE procedure allows a subscriber to register interest in a change set associated with source tables of interest.EXECUTE sys.DBMS_CDC_SUBSCRIBE.GET_SUBSCRIPTION_HANDLE(\ CHANGE_SET=>'SYNC_SET', \ DESCRIPTION=>'Change data for emp',\ SUBSCRIPTION_HANDLE=>:subhandle);
This procedure specifies the source tables and source columns for which the subscriber wants to access change data.
There are two versions of syntax for the SUBSCRIBE procedure, each of which specifies the subscriber columns and datatypes. If the subscribers know which publication contains the source columns of interest, the subscribers can use the version of the procedure that contains the publication ID. If they do not know the publication ID, the Change Data Capture system will select a publication based on the supplied source schema and source table.
The following syntax identifies the source table of interest, allowing Change Data Capture to select any publication that contains all source columns of interest.
DBMS_LOGMNR_CDC_SUBSCRIBE.SUBSCRIBE (subscription_handle IN NUMBER,source_schema IN VARCHAR2,source_table IN VARCHAR2,column_list IN VARCHAR2);
The following syntax specifies the publication ID for a specific publication that contains the source columns of interest.
DBMS_LOGMNR_CDC_SUBSCRIBE.SUBSCRIBE (subscription_handle IN NUMBER,publication_id IN NUMBER,column_list IN VARCHAR2);
ALL_PUBLISHED_COLUMNS view.SUBSCRIBE procedure allows an application to subscribe to one or more published source tables and to specific columns in each source table.EXECUTE sys.DBMS_CDC_SUBSCRIBE.SUBSCRIBE(\ SUBSCRIPTION_HANDLE=>:subhandle, \ SOURCE_SCHEMA=>'scott', \ SOURCE_TABLE=>'emp', \ COLUMN_LIST=>'empno, ename, hiredate');
The ACTIVATE_SUBSCRIPTION procedure indicates that a subscription is ready to start accessing change data.
DBMS_CDC_SUBSCRIBE.ACTIVATE_SUBSCRIPTION (subscription_handle IN NUMBER);
| Parameter | Description | 
|---|---|
| 
 | Unique number of the subscription handle that was returned by a previous call to the  | 
ACTIVATE_SUBSCRIPTION procedure indicates that you are finished subscribing to tables, and the subscription is ready to start accessing data.EXTEND_WINDOW procedure to see the initial set of change data.EXECUTE sys.DBMS_CDC_SUBSCRIBE.ACTIVATE_SUBSCRIPTION( \ SUBSCRIPTION_HANDLE=>:subhandle);
This procedure sets the subscription window boundaries (low-water and high-water mark) so that new change data can be seen.
DBMS_LOGMNR_CDC_SUBSCRIBE.EXTEND_WINDOW (subscription_handle IN NUMBER);
| Parameter | Description | 
|---|---|
| 
 | Unique number of the subscription handle that was returned by a previous call to the  | 
EXTEND_WINDOW procedure to begin capturing change data, the subscription window remains empty. 
EXECUTE sys.DBMS_CDC_SUBSCRIBE.EXTEND_WINDOW( \ subscription_handle=>:subhandle);
This procedure creates a subscriber view in the subscriber's schema in which the subscriber can query the change data encompassed by the current subscription window.
DBMS_LOGMNR_CDC_SUBSCRIBE.PREPARE_SUBSCRIBER_VIEW ( subscription_handle IN NUMBER, source_schema IN VARCHAR2, source_table IN VARCHAR2, view_name OUT VARCHAR2);
EXTEND_WINDOW procedure) for the subscription window.SELECT statement from these views and retrieve the change data. For the purpose of the following example, assume that sys.sub9view was the view name returned by the PREPARE_SUBSCRIBER_VIEW procedure: 
SELECT * FROM sys.sub9view; . . .
view_name (for example, if the previous view was not dropped with a DROP VIEW DDL statement), an exception occurs. The PREPARE_SUBSCRIBER_VIEW procedure checks if the underlying change table still exists.EXECUTE sys.DBMS_CDC_SUBSCRIBE.PREPARE_SUBSCRIBER_VIEW( \ SUBSCRIPTION_HANDLE =>:subhandle, \ SOURCE_SCHEMA =>'scott', \ SOURCE_TABLE => 'emp', \ VIEW_NAME => :viewname);
This procedure drops a subscriber view from the subscriber's schema.
DBMS_LOGMNR_CDC_SUBSCRIBE.DROP_SUBSCRIBER_VIEW ( subscription_handle IN NUMBER, source_schema IN VARCHAR2, source_table IN VARCHAR2);
DBMS_LOGMNR_CDC_SUBSCRIBE.PREPARE_SUBSCRIBER_VIEW procedure.DBMS_LOGMNR_CDC_SUBSCRIBE.DROP_SUBSCRIPTION procedure.EXECUTE sys.DBMS_CDC_SUBSCRIBE.DROP_SUBSCRIBER_VIEW( \ SUBSCRIPTION_HANDLE =>:subhandle, \ SOURCE_SCHEMA =>'scott', \ SOURCE_TABLE => 'emp');
The subscriber calls this procedure to notify the capture system it is finished processing a block of changes. The PURGE_WINDOW procedure sets the low-water mark so that the subscription no longer sees any data, effectively making the subscription window empty.
DBMS_CDC_SUBSCRIBE.PURGE_WINDOW( subscription_handle IN NUMBER);
| Parameter | Description | 
|---|---|
| 
 | Unique number of the subscription handle that was returned by a previous call to the  | 
| Exception | Description | 
|---|---|
| 
 | Subscription handle does not exist or handle does not belong to this user. Call the function again with a valid subscription handle. | 
| 
 | The subscription handle must be activated before you use the  | 
| 
 | The subscriber view was not dropped prior to making this call. Call the DROP_SUBSCRIBER_VIEW Procedure and then try the original command again. | 
PURGE_WINDOW procedure. By this action the subscriber performs the following functions: 
The Change Data Capture system manages the change data to ensure that it is available as long as there are subscribers who need it.
EXECUTE sys.DBMS_CDC_SUBSCRIBE.PURGE_WINDOW ( \ SUBSCRIPTION_HANDLE=>:subhandle);
This procedure drops a subscription that was created with a prior call to the GET_SUBSCRIPTION_HANDLE procedure.
DBMS_LOGMNR_CDC_SUBSCRIBE.DROP_SUBSCRIPTION ( subscription_handle IN NUMBER);
| Parameter | Description | 
|---|---|
| 
 | Unique number of the subscription handle that was returned by a previous call to the  | 
DBMS_LOGMNR_CDC_SUBSCRIBE.DROP_SUBSCRIBER_VIEW procedure.EXECUTE DBMS_LOGMNR_CDC_SUBSCRIBE.DROP_SUBSCRIPTION (\
SUBSCRIPTION_HANDLE => :subhandle);
| 
 |  Copyright © 2000, 2002 Oracle Corporation. All Rights Reserved. | 
 |