Results 1 to 1 of 1

Thread: Updating Primary Keys

  1. #1
    JeffInFlorida's Avatar
    JeffInFlorida is offline US Technical Team
    Join Date
    Oct 2006
    Posts
    83
    Rep Power
    6

    Default Updating Primary Keys

    When a change is encountered for a primary key and the Apply Policy is set to defensive then you can end up with duplicate rows in the target database.
    To be able to update primary keys on a target database you have to delete the existing primary key and then insert the new primary key. In order to get the old primary key you need to have the Before Image of the change.
    In order to get the before images perform the following steps:
    1) Run the Support.bat file that is in the CDC directory of the solution.
    2) Export the machine configuration using the following command:
    NAV_UTIL EXPORT MACHINE MACHINE.XML
    3) Edit the MACHINE.XML file and add the getBeforeImage attribute to the CDC_AGENT adapter config.
    <adapter name='CDC_AGENT' type='sqlCDCA' definition='CDC_AGENT'>
    <config datasource='BULK' logLevel='none' checkTimeoutEveryNEvents='100'
    realTime='true' retryInterval='2' lgrAutoConfig='true' getBeforeImage='true'>
    4) Import the configuration .
    NAV_UTIL IMPORT SYS MACHINE.XML
    5) Stop and start the CDC solution using the Management Console.

    Make the following changes to CDC Package for each table.
    1) Add a Transformation Script component between the Change Source and Change Destination components.
    2) Connect the component to the Change Source.
    3) Edit the script component and make the following changes:
    a. On the Input Columns check the operation column and change the Usage Type to ‘ReadWrite’.
    b. Edit the script and add the following code in the ‘Input0_ProcessInputRow’ function.
    if (Row.operation.Trim() == "BEFOREIMAGE")
    Row.operation = "DELETE";
    if (Row.operation.Trim() == "UPDATE")
    Row.operation = "INSERT";
    4) Save the scipt.
    5) Connect the Script Component to the Destination Component.
    Last edited by JeffInFlorida; 01-26-2011 at 09:04 AM.
    To Find Out more About Attunity Technology:
    Attunity
    or:
    Contact Us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243