0

I am wondering if there is a way to delay Delete transactions in an SQR program? I am having an issue where I am deleting data from a table that has a trigger on it that inserts rows into another (Audit) table and the only key on the table that can be altered is a date/time stamp, but because these transactions are occuring at the exact same time (down to the hundreth of a second) it is causing duplicate insert errors on the sql trigger. I was hoping if there is a way to delay each row to be deleted in SQR that would be a good work-around to this issue. Thanks!

BEGIN-PROCEDURE DELETE-PSROLEUSER-ROLES

SHOW 'BEGINNING DELETE-PSROLEUSER-ROLES'

BEGIN-SQL
DELETE PSRO
FROM PSROLEUSER PSRO
INNER JOIN PS_GH_AD_X_WALK B ON B.OPRID = PSRO.ROLEUSER
INNER JOIN HRDEV01_FOR_BUDGET_MODULE.HRDEV92B.dbo.PS_JOB C ON C.EMPLID = B.GH_AD_EMPLID AND B.GH_AD_EMPLID <> ''
WHERE C.EFFDT = 
(SELECT MAX(A_ED.EFFDT) FROM HRDEV01_FOR_BUDGET_MODULE.HRDEV92B.dbo.PS_JOB A_ED 
WHERE C.EMPLID = A_ED.EMPLID 
AND C.EMPL_RCD = A_ED.EMPL_RCD 
AND A_ED.EFFDT <= SUBSTRING(CONVERT(CHAR,GETDATE(),121), 1, 10)) 
AND C.ACTION = 'TER'
END-SQL

END-PROCEDURE DELETE-PSROLEUSER-ROLES
4

1 回答 1

0

请将所有内部连接移至删除的 where 子句。您可能不打算从这些内部联接表中删除行,其中一些可能会为一个 emplid 返回多行。

于 2019-04-23T20:32:31.317 回答