开发者

Output Parameters used with update CASCADE issue, when using data adapters

开发者 https://www.devze.com 2023-03-04 23:38 出处:网络
I\'ve manually created some data adapters – using the auto-generated ones is not viable due to version incompatibilities, for a dataset made of a number of tables with the usual mixture of PK, FK con

I've manually created some data adapters – using the auto-generated ones is not viable due to version incompatibilities, for a dataset made of a number of tables with the usual mixture of PK, FK constraints. Most of its working pretty smoothly so far, but after modifying the adapters to use DB sequences for the PKs (instead of the temporary one assigned to the rows in the dataset) when updating the DB with new ‘added’ rows, I’ve been hitting problems.

I added the sequences into the insert statements and changed PK parameter to output parameters, so that it would update the dataset row and thus update all the child rows as well (with the UPDATE CASCADE rule). The problem is that the child rows, that, before the update had a row state of added, are changed to a state of modified (I don’t agree this should even be happening, surely an added row should stay as added even if it’s modified!). Thus when we get round to updating the child table with the child rows, it fails as its expecting rows with the added state.

What’s the cleanest way I could get around this problem? Potential solutions I can think of:

  • Turning off UPDATE CASCADE and updating each child row manually after, updating the parents PK and changing each row back to added, after modifying it.
  • Creating a copy of the all the added rows in all table开发者_StackOverflow中文版s of the dataset before starting updates and then updating the main copy after each tables updates marking all the correct rows back to added.

Any better ideas?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号