I am attempting to update a table on our AS400 from a SQL Server 2008 stored proc using a linked server.
This generates the following error message:
OLE DB provider "IBMDA400" for linked server "ADM_AS400_LPAR" returned message "Key column information is insufficient or incorrect. Too many rows were affected by update.".
The strange thing is that the update completes successfully eventhough I'm receiving the error message. Now I don't get the error message when I'm only updating one record, but the select query will often return multiple rows. That is when I get the error message. But it is intential that the query will often return multiple rows because in that scenerio I am trying to update multiple rows. And like I mentioned before, it does successfully update multiple records on the AS400. I just cannot figure out how to make the error message to go-away. As a temporay work-around, I've placed the code in a try-catch block, but I'm looking for a better solution.
I've also tried the following version of the query, but the results are the same. I still get the error message.
Code:
UPDATE OPENQUERY( ADM_AS400_LPAR,
'SELECT grbpqs AS RequestStatus,
FROM xggndta.zagrdf00 a
WHERE grbpqs = ''10''
AND grcrda = 1100809
AND grcrti = 1514
AND grbptr = ''CHIRO13343'' ')
SET RequestStatus = '20'
OLE DB provider "IBMDA400" for linked server "ADM_AS400_LPAR" returned message "Key column information is insufficient or incorrect. Too many rows were affected by update.".
The strange thing is that the update completes successfully eventhough I'm receiving the error message. Now I don't get the error message when I'm only updating one record, but the select query will often return multiple rows. That is when I get the error message. But it is intential that the query will often return multiple rows because in that scenerio I am trying to update multiple rows. And like I mentioned before, it does successfully update multiple records on the AS400. I just cannot figure out how to make the error message to go-away. As a temporay work-around, I've placed the code in a try-catch block, but I'm looking for a better solution.
I've also tried the following version of the query, but the results are the same. I still get the error message.
Code:
UPDATE OPENQUERY( ADM_AS400_LPAR,
'SELECT
grbpqs AS RequestStatus,
grcrda AS BatchCreateDate,
grcrti AS BatchCreateTime,
grbptr AS JobTypeReference
FROM ddiamond.zagrdf00 a ')
SET RequestStatus = '20'
WHERE RequestStatus = '10'
AND BatchCreateDate = 1100809
AND BatchCreateTime = 1534
AND JobTypeReference = 'CHIRO14350'