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

Create CDC policies

The following code is an example for creating CDC table policies:
using OpenEdge.DataAdmin.Error.DataAdminErrorHandler from propath.
using OpenEdge.DataAdmin.ICdcTablePolicy 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 tablePolicy as ICdcTablePolicy 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:NewCdcTablePolicy("test").
tbl = service:GetTable("customer","PUB").
assign
tablePolicy:Table = tbl
tablePolicy:Level = CdcTablePolicyLevelEnum:MAXIMUM
tablePolicy:State = CdcTablePolicyStateEnum:Active
tablePolicy:IdentifyingField = YES
tablePolicy:EncryptPolicy = no
tablePolicy:ChangeTable = "changeTable"
tablePolicy:ChangeTableOwner = "PUB"
tablePolicy:DataArea = service:GetArea("customer index area")
tablePolicy:IndexArea = service:GetArea("customer index area")
tablePolicy:Description = "desc"
.

fieldPolicy = service:NewCdcFieldPolicy().
tablePolicy:FieldPolicies:add(fieldPolicy).
fieldPolicy:Field = tbl:Fields:Find("name").
fieldPolicy:IdentifyingField = 1.

fieldPolicy = service:NewCdcFieldPolicy().
tablePolicy:FieldPolicies:add(fieldPolicy).
fieldPolicy:Field = tbl:Fields:Find("city").
fieldPolicy:IdentifyingField = 2.

service:CreateCdcTablePolicy(tablePolicy).