Attempting to update DB2 from ADF using pre-copy script of copy activity

MahderNegash-7441 1 Reputation point
2021-12-17T15:59:30.383+00:00

The objective is to be able to update Phoenix data from ADF using ODBC connector.

I am considering to use Pre-Copy script feature in Azure Data factory Copy activity.

Using this feature I am able to update the records I wanted but the copy activity shows failure with the below error.

Error code2200
Failure typeUser configuration issue
DetailsFailure happened on 'Sink' side. ErrorCode=UserErrorOdbcOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=ERROR [23000] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0803 - Duplicate key value specified.,Source=Microsoft.DataTransfer.ClientLibrary.Odbc.OdbcConnector,''Type=Microsoft.DataTransfer.ClientLibrary.Odbc.Exceptions.OdbcException,Message=ERROR [23000] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0803 - Duplicate key value specified.,Source=CWBODBC.DLL,'

The query I used is
UPDATE
"CMDDB"."NCC_DETAIL_CREDIT"
SET
NCC_STATUS = 'y'
WHERE NCC_TYPE = 'SIP'

I am assuming this error is application error from DB2, and there is some key (created by unique sequence number generator) being reset whenever the copy activity is run. How can make this work what am I missing?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,625 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. KranthiPakala-MSFT 46,642 Reputation points Microsoft Employee Moderator
    2021-12-21T02:19:45.02+00:00

    Hi anonymous user,

    Thanks for using Microsoft Q&A forum and posting your query.

    From the error message shared, the issue seems to be more of DB2 side. My understanding is that one of your field/column has the primary key constraint and if you try to update that field/column with the value which is already present in the table then it will give you such error message

    I would recommend you to please refer to these related thread for troubleshooting:

    In case if you further need assistance in troubleshooting this, I would recommend you to please reach out in IBM community forum for better assistance as it is more related to DB2.
    IBM community forum: https://www.ibm.com/mysupport/s/forumshome

    Hope this info helps.

    ----------

    • Please don't forget to click on 130616-image.png and upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

  2. KranthiPakala-MSFT 46,642 Reputation points Microsoft Employee Moderator
    2021-12-22T21:25:52.123+00:00

    Hi anonymous user, Thanks for clarifying about requirement. Your requirement is only to update the records and no copy/insert of records is needed - which is why you are just using the Pre-copy script in ADF copy activity. Please correct if I misunderstood your requirement.

    I don't think copy activity is appropriate in this use case. Copy activity is intended to copy/insert the data from a source to a destination.
    But as per your requirement, in order to just update the DB2 records, I would recommend you to use Lookup activity in ADF which would help achieve your requirement. Please make sure that your query returns one and exact one result set. Otherwise, Lookup activity fails. Lookup activity expects a response from the query executed.

    Below are the supported capabilities of Lookup activity:

    159826-image.png

    Hope this info helps. Do let us know if you have further query.

    ----------

    • Please don't forget to click on 130616-image.png and upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.