Try OpenEdge Now
skip to main content
Programming Interfaces
Change Data Capture ABL references : Code examples : Update CDC policies
 

Update CDC policies

The following code is an example for updating CDC table policies:
using OpenEdge.DataAdmin.Error.DataAdminErrorHandler from propath.
using OpenEdge.DataAdmin.ICdcTablePolicy from propath.
using OpenEdge.DataAdmin.ICdcTablePolicyset from propath.
using OpenEdge.DataAdmin.ICdcFieldPolicySet from propath.
using OpenEdge.DataAdmin.ICdcFieldPolicy from propath.
using OpenEdge.DataAdmin.ITable from propath.
using OpenEdge.DataAdmin.cdctablepolicystateenum.
using OpenEdge.DataAdmin.cdctablepolicylevelenum.

define variable service as OpenEdge.DataAdmin.DataAdminService no-undo.
define variable errorHandler as DataAdminErrorHandler no-undo.
define variable tablePolicy as ICdcTablePolicy no-undo.
define variable tablePolicies as ICdcTablePolicyset no-undo.
define variable FieldPolicies as ICdcFieldPolicyset no-undo.
define variable FieldPolicy as ICdcFieldPolicy no-undo.
define variable tbl as ITable no-undo.

service = new OpenEdge.DataAdmin.DataAdminService(ldbname(1)).

tablePolicy = service:GetCdcTablePolicy("MyPolicy").
FieldPolicies = tablePolicy:FieldPolicies.
tbl = service:GetTable(tablePolicy:Name).

/* update table policy properties */
tablepolicy:DataArea = service:Getarea("Primary Index Area").
tablepolicy:level = cdctablepolicylevelenum:Maximum.
tablepolicy:state = cdctablepolicystateenum:active.
tablepolicy:Name = "nameChanged".
tablepolicy:EncryptPolicy = yes.
tablepolicy:Description = "modified".
tablepolicy:IdentifyingField = no.

/* to add new field policy */
fieldPolicy = service:NewCdcFieldPolicy().
tablePolicy:FieldPolicies:add(fieldPolicy).
fieldPolicy:Field = tbl:Fields:Find("Amount").
fieldPolicy:IdentifyingField = 3.

/* modify existing field policy */
fieldPolicy = fieldpolicies:Find("Country").
fieldPolicy:IdentifyingField = 3.

service:UpdateCdcTablePolicy(tablePolicy).