Namespace: OpenEdge.DataAdmin.Util
Class
CDCTrackingHelper
Parent classes:
Inherits: Progress.Lang.Object

/* Copyright (c) 2017 by Progress Software Corporation
/*
/* All rights reserved. No part of this program or document
/* may be reproduced in any form or by any means without
/* permission in writing from Progress Software Corporation.
File:CDCTrackingHelper
Purpose:Provides convenience methods for accessing data in a
_Cdc-Change-Tracking record and its related change table
records.
Notes:An ETL program can create an instance of CDCTrackingHelper
for the source table being processed. The ETL program
creates a CDCTrackingHelper object for a
_Cdc-Change-Tracking buffer, then iterates through the
_Cdc-Change-Tracking records using this buffer. The ETL
program can then use the convenience methods in the
CDCTrackingHelper object to access the record currently
in the buffer.
/* NOTES:




Method Summary
Options Name Purpose
cachePolicy ()
LOGICAL ChangeBitSet (raw, integer)
HANDLE CreateChangeBuffer () /** Returns a buffer handle for a dynamic temp-table that matches the definition of the change table for a given source table (without the meta-fields). This is a convenience method for users to obtain a buffer match the change table for use with the FetchChangeRecord() methods. Multiple calls to this method will return the same buffer handle. The temp-table is created dynamically inside the CDCTrackingHelper object. It is deleted when the CDCTrackingHelper object is detroyed. */
DeleteChangeTrackingRecord () /** Deletes the _Cdc-Change-Tracking record currently in the buffer, along with any related change table records. This is a convenience method to allow users to purge the change tracking record and the change table records for the current _Cdc-Change-Tracking record. This helps to ensure the referential integrity between the _Cdc-Change-Tracking and change table records in one convenient method. The caller must have a started a transaction to call this method. No AppError is thrown if there are change table records for the _Cdc-Change-Tracking record, because the ETL program has most likely dealt with any discrepancy, and now just wants to purge the data. */
FetchChangeRecord (handle) /** Fetches change table records that match the current _Cdc-Change-Tracking record, with the same _Operation. It copies the fields from the change table row into the buffer passed, based on the field names. The passed buffer should be from a table with a similar schema to the schema of the change table (without the meta-fields). There are between 0 and 2 change table records for each _Cdc-Change-Tracking/_Operation combination. Typically there are 0 or 1; 2 is the case of a split record. In the case of a split record, this method copies the change data from both change table records into the input buffer. If no change table record is found, this method throws an AppError. Note that for some CDC operations, there are no change table records, so users should be careful to call this only when necessary, and/or catch and handle AppErrors appropriately. In the case of an UPDATE _Cdc-Change-Tracking record, this method returns the data from the AFTER change table record. @param handle Handle to a buffer of a table into which to write the field from the change table record */
FetchChangeRecord (handle, logical) /** This method is similar to FetchChangeRecord(hbuf), but this overload can look for change table records where the _Operation reflects a BEFORE record. In the case of a Level 3 CDC policy, there are two change tracking records for a _Cdc-Change-Tracking UPDATE record, a BEFORE and an AFTER record. If the input parameter is TRUE, this method copies the BEFORE record. If the input parameter is FALSE, this method copies the AFTER record. If no change table record is found, this method throws an AppError. Note that for some CDC operations, there are no change table records, so users should be careful to call this only when necessary, and/or catch and handle AppErrors appropriately. @param handle Handle to a buffer of a table into which to write the field from the change table record @param logical If the operation is an update, then retrieve the BEFORE record */
LOGICAL FieldChanged (character) /** Returns TRUE if the given fieldname was changed in the record currently in the _Cdc-Change-Tracking buffer, according to the _Change-FieldMap. If the field does not exist in the change table, an AppError is thrown. @param character The name of the field to query */
CHARACTER GetChangedFields () /** Returns an EXTENT of the field names of fields which were flagged as changed in the _Cdc-Change-Tracking record's _Change-FieldMap. If there are no changed fields (this is a level 0 CDC policy), an indeterminate array is returned */
OpenEdge.DataAdmin.Util.CDCOperation GetOperation () /** Returns a CDCOperation enum value for the operation in the record currently in the _Cdc-Change-Tracking buffer. This method provides Enums for all possible _Operation values. Frequent _Operation values for CREATE, UPDATE and DELETE have separate methods to provide faster evaluation. */
InternalFetchChangeRecord (handle, integer) /* NOTE: Using an INTEGER parameter for the operation in this * internal method. The public API never receives a CDCOperation. * The operation value is either the INTEGER value of * CDCOperation:BeforeUpdate, or the INTEGER value extracted from * the _Cdc-Change-Tracking record. The value is then used as an * INTEGER when building a query. The conversion from an INTEGER * to a CDCOperation Enum just so it can be converted back to an * INTEGER is unnecessary processing. There is little advantage of * type safety if this stays an internal routine. */
LOGICAL InternalIsRecordSplit (integer) /* NOTE: Using an INTEGER parameter for the operation in this * internal method. The public API never receives a CDCOperation. * The operation value is either the INTEGER value of * CDCOperation:BeforeUpdate, or the INTEGER value extracted from * the _Cdc-Change-Tracking record. The value is then used as an * INTEGER when building a query. The conversion from an INTEGER * to a CDCOperation Enum just so it can be converted back to an * INTEGER is unnecessary processing. There is little advantage of * type safety if this stays an internal routine. */
LOGICAL IsCreate () /** Returns whether the _Cdc-Change-Tracking record reflects a CREATE operation. This method is provided as a an alternative to the GetOperation method(), as a CREATE operation is a frequent operation in a change table. */
LOGICAL IsDelete () /** Returns whether the _Cdc-Change-Tracking record reflects a DELETE operation. This method is provided as a an alternative to the GetOperation method(), as a DELETE operation is a frequent operation in a change table. */
LOGICAL IsRecordSplit () /** Returns TRUE if the change details were split between two records, and FALSE otherwise. This method looks for change table rows that match the current _Cdc-Change-Tracking record, using the _Operation from the _Cdc-Change-Tracking record. If there is more than one change table record, this means the change details were split between two change table records. In the case of a level 3 CDC policy, there may be two change records for a _Cdc-Change_Tracking record, a BEFORE record and an AFTER record. This method returns whether the AFTER record was split. If no change table record exists that matched the _Cdc-Change-Tracking record, this method will return FALSE. Note that for some CDC operations, there are no change table records, so callers should be careful to call this only when necessary, and/or check for a FALSE return value. This method is provided so that an ETL program can choose not to call FetchChangeRecord() if the change table record is not split. Instead, the ETL program can choose to perform the FIND directly on the change table. Direct ABL access is faster than calling a method to potentially rejoin a record if there is no need. */
LOGICAL IsRecordSplit (logical) /** Returns TRUE if the change details were split between two records, and FALSE otherwise. This method is similar to the IsRecordSplit() method, but this overload can loko for change table records where the _Operation reflects a BEFORE record. In the case of a Level 3 CDC policy, there are two change tracking records for a _Cdc-Change-Tracking update record, a BEFORE and an AFTER record. If the input parameter is TRUE, this method returns whether the BEFORE record was split. If the input parameter is FALSE, this method returns whether the AFTER row was split. If no change table row exists that matches the _Cdc-Change-Tracking record, this method will return FALSE. Note that for some CDC operations, there are no change table records, so users should be careful to call this only when necessary, and/or check for a FALSE return value. @param logical If the operation is an update, then retrieve the BEFORE record */
LOGICAL IsUpdate () /** Returns whether the _Cdc-Change-Tracking record reflects an UPDATE operation. This method is provided as a an alternative to the GetOperation method(), as an UPDATE operation is a frequent operation in a change table. */

Constructor Summary
Options Name Purpose
CDCTrackingHelper (character, character, handle) /** Creates a new CDCTrackingHelper object for the given source table in the given schema, in the database associated with the ChangeTrackingHandle. @param character The name of the source table. @param character The Owner (schema) of the source table, allowing users to identify SQL source tables. @param handle A handle to a _Cdc-Change-Tracking buffer, which the ETLprogram will use to set up a custom query on the _Cdc-Change-Tracking table. */
CDCTrackingHelper (character, handle) /** Creates a new CDCTrackingHelper object for the given source table in the PUB schema, in the database associated with the ChangeTrackingHandle. @param character The name of the source table. @param handle A handle to a _Cdc-Change-Tracking buffer, which the ETLprogram will use to set up a custom query on the _Cdc-Change-Tracking table. */

Property Summary
Options Name Purpose
INTEGER SourceTableNumber


Method Detail
Top

cachePolicy ()

Top

LOGICAL ChangeBitSet (raw, integer)

Parameters:
rbitmap RAW
ipos INTEGER
Returns LOGICAL
Top

HANDLE CreateChangeBuffer ()

Purpose: Returns a buffer handle for a dynamic temp-table that matches
the definition of the change table for a given source table
(without the meta-fields).
This is a convenience method for users to obtain a buffer
match the change table for use with the FetchChangeRecord() methods.
Multiple calls to this method will return the same buffer handle.
The temp-table is created dynamically inside the CDCTrackingHelper
object. It is deleted when the CDCTrackingHelper object is detroyed.
Returns HANDLE
Top

DeleteChangeTrackingRecord ()

Purpose: Deletes the _Cdc-Change-Tracking record currently in the buffer,
along with any related change table records. This is a convenience
method to allow users to purge the change tracking record and the
change table records for the current _Cdc-Change-Tracking record.
This helps to ensure the referential integrity between the
_Cdc-Change-Tracking and change table records in one convenient
method.
The caller must have a started a transaction to call this method.
No AppError is thrown if there are change table records for the
_Cdc-Change-Tracking record, because the ETL program has most likely
dealt with any discrepancy, and now just wants to purge the data.
Top

FetchChangeRecord (handle)

Purpose: Fetches change table records that match the current
_Cdc-Change-Tracking record, with the same _Operation. It copies
the fields from the change table row into the buffer passed,
based on the field names. The passed buffer should be from a
table with a similar schema to the schema of the change table
(without the meta-fields).
There are between 0 and 2 change table records for each
_Cdc-Change-Tracking/_Operation combination. Typically there are
0 or 1; 2 is the case of a split record. In the case of a split
record, this method copies the change data from both change
table records into the input buffer. If no change table record is
found, this method throws an AppError.
Note that for some CDC operations, there are no change table
records, so users should be careful to call this only when
necessary, and/or catch and handle AppErrors appropriately.
In the case of an UPDATE _Cdc-Change-Tracking record, this method
returns the data from the AFTER change table record.
Parameters:
phChangeBuffer HANDLE
Top

FetchChangeRecord (handle, logical)

Purpose: This method is similar to FetchChangeRecord(hbuf), but this
overload can look for change table records where the
_Operation reflects a BEFORE record.
In the case of a Level 3 CDC policy, there are two change
tracking records for a _Cdc-Change-Tracking UPDATE record,
a BEFORE and an AFTER record. If the input parameter is TRUE,
this method copies the BEFORE record. If the input parameter is
FALSE, this method copies the AFTER record. If no change table
record is found, this method throws an AppError.
Note that for some CDC operations, there are no change table records,
so users should be careful to call this only when necessary,
and/or catch and handle AppErrors appropriately.
Parameters:
phChangeBuffer HANDLE
plBefore LOGICAL
Top

LOGICAL FieldChanged (character)

Purpose: Returns TRUE if the given fieldname was changed
in the record currently in the _Cdc-Change-Tracking buffer,
according to the _Change-FieldMap.
If the field does not exist in the change table,
an AppError is thrown.
Parameters:
ccolname CHARACTER
Returns LOGICAL
Top

CHARACTER GetChangedFields ()

Purpose: Returns an EXTENT of the field names of fields which were flagged as
changed in the _Cdc-Change-Tracking record's _Change-FieldMap.
If there are no changed fields (this is a level 0 CDC policy),
an indeterminate array is returned
Returns CHARACTER
Top

OpenEdge.DataAdmin.Util.CDCOperation GetOperation ()

Purpose: Returns a CDCOperation enum value for the operation
in the record currently in the _Cdc-Change-Tracking buffer.
This method provides Enums for all possible _Operation values.
Frequent _Operation values for CREATE, UPDATE and DELETE
have separate methods to provide faster evaluation.
Returns OpenEdge.DataAdmin.Util.CDCOperation
Top

InternalFetchChangeRecord (handle, integer)

/* NOTE: Using an INTEGER parameter for the operation in this
Parameters:
hchgrow HANDLE
iOperation INTEGER
Top

LOGICAL InternalIsRecordSplit (integer)

/* NOTE: Using an INTEGER parameter for the operation in this
Parameters:
iOperation INTEGER
Returns LOGICAL
Top

LOGICAL IsCreate ()

Purpose: Returns whether the _Cdc-Change-Tracking record reflects a CREATE
operation. This method is provided as a an alternative to the
GetOperation method(), as a CREATE operation is a frequent
operation in a change table.
Returns LOGICAL
Top

LOGICAL IsDelete ()

Purpose: Returns whether the _Cdc-Change-Tracking record reflects a DELETE
operation. This method is provided as a an alternative to the
GetOperation method(), as a DELETE operation is a frequent
operation in a change table.
Returns LOGICAL
Top

LOGICAL IsRecordSplit ()

Purpose: Returns TRUE if the change details were split between two records,
and FALSE otherwise.
This method looks for change table rows that match the current
_Cdc-Change-Tracking record, using the _Operation from the
_Cdc-Change-Tracking record. If there is more than one change table
record, this means the change details were split between two change
table records.
In the case of a level 3 CDC policy, there may be two change records
for a _Cdc-Change_Tracking record, a BEFORE record and an AFTER record.
This method returns whether the AFTER record was split.
If no change table record exists that matched the _Cdc-Change-Tracking
record, this method will return FALSE.
Note that for some CDC operations, there are no change table records,
so callers should be careful to call this only when necessary,
and/or check for a FALSE return value.
This method is provided so that an ETL program can choose not to call
FetchChangeRecord() if the change table record is not split.
Instead, the ETL program can choose to perform the FIND directly on
the change table. Direct ABL access is faster than calling a method to
potentially rejoin a record if there is no need.
Returns LOGICAL
Top

LOGICAL IsRecordSplit (logical)

Purpose: Returns TRUE if the change details were split between two records,
and FALSE otherwise.
This method is similar to the IsRecordSplit() method, but this
overload can loko for change table records where the _Operation
reflects a BEFORE record.
In the case of a Level 3 CDC policy, there are two change tracking
records for a _Cdc-Change-Tracking update record, a BEFORE and an
AFTER record. If the input parameter is TRUE, this method returns
whether the BEFORE record was split. If the input parameter is FALSE,
this method returns whether the AFTER row was split.
If no change table row exists that matches the _Cdc-Change-Tracking
record, this method will return FALSE.
Note that for some CDC operations, there are no change table records,
so users should be careful to call this only when necessary,
and/or check for a FALSE return value.
Parameters:
lBefore LOGICAL
Returns LOGICAL
Top

LOGICAL IsUpdate ()

Purpose: Returns whether the _Cdc-Change-Tracking record reflects an UPDATE
operation. This method is provided as a an alternative to the
GetOperation method(), as an UPDATE operation is a frequent
operation in a change table.
Returns LOGICAL


Constructor Detail
Top

CDCTrackingHelper (character, character, handle)

Purpose: Creates a new CDCTrackingHelper object for the given source table in
the given schema, in the database associated with the ChangeTrackingHandle.
Parameters:
pcSourceTableName CHARACTER
pcTableOwner CHARACTER
phChangeTrackingBuffer HANDLE
Top

CDCTrackingHelper (character, handle)

Purpose: Creates a new CDCTrackingHelper object for the given source table in
the PUB schema, in the database associated with the ChangeTrackingHandle.
Parameters:
pcSourceTableName CHARACTER
phChangeTrackingBuffer HANDLE


Property Detail
Top

INTEGER SourceTableNumber

Returns INTEGER


Copyright © 2022 Progress Software Corporation. All rights Reserved.

Progress® OpenEdge® Release 11.7.15