Resolving unique constraint violations in PeopleSoft processes

Anyonewho has supported PeopleSoft applications long enough is all too familiar withthe dreaded ORA-0805 error, a unique constraint violation. That error mostfrequently occurs when a process tries to insert a row into a table with thesame key values as a row that is already there, although it can also happen onan update statement. 

Fortunately, this is oneproblem that can be fixed rather rapidly if you're adept at trouble-shooting. Isee it most often on the voucher posting process, which is an App Engine, soI'll approach the problem from that standpoint, but a lot of this holds truefor SQRs, too, although it's a little trickier because data might not have beencommitted at any point during the process.

Let's assume that your processhas failed. The log file should display the entire insert statement; if you'vegot AE trace enabled, you can also get it from the trace file. Copy thatstatement and run it in a SQL tool. I use TOAD, because I can have numerouswindows open at a time and statements can be recalled simply by hitting F8. Runthe statement in the SQL tool and if you're lucky, you'll get the same error.That's not always the case, though, if statements that preceded the insert wererolled back after the error occurred. In that case, you'll have to go to thetrace file, find the last commit that occurred prior to the error, and run allof the statements up to and including the one that fails. Be sure to keep trackof the statements that insert or update data, though, because you'll want toput things back the way they were after you've got the problem resolved andbefore you restart the AE process. If AE trace was not enabled, turn it on inthe Process Scheduler config file and restart the failed process. It will failagain, but now you'll at least have a trace file. Be sure to disable trace,though, or pretty soon you'll have space problems on the Process Scheduler box.

Once you've replicated theerror, it's a simple matter of finding the bad row and deleting it from what isusually an AE temp table. How do you find it? First, you need to determine thekeys of the table into which the row is being inserted. Second, you need toanalyze the insert statement to determine the source of the bad row. In thecase of the voucher post process, it's usually VCHR_TEMP_LNx, where x is theinstance number of the table being used. Third, you need to write a query tofind the row in the source table that is a duplicate of a row in the targettable. You do that by querying the two tables for rows with duplicate keyvalues. Your SQL statement will end up looking something like this:

SELECT * FROM PS_VCHR_TEMP_LN11A
WHERE EXISTS
(SELECT 'X' FROMPS_VCHR_ACCTG_LINE B
WHEREA.BUSINESS_UNIT=B.BUSINESS_UNIT
AND A.VOUCHER_ID=B.VOUCHER_ID
AND A.UNPOST_SEQ=B.UNPOST_SEQ
ANDA.APPL_JRNL_ID=B.APPL_JRNL_ID
ANDA.DST_ACCT_TYPE=B.DST_ACCT_TYPE
AND A.PYMNT_CNT=B.PYMNT_CNT
ANDA.VOUCHER_LINE_NUM=B.VOUCHER_LINE_NUM
ANDA.DISTRIB_LINE_NUM=B.DISTRIB_LINE_NUM
ANDA.DST_ACCT_TYPE=B.DST_ACCT_TYPE
ANDA.CF_BAL_LINE_NUM=B.CF_BAL_LINE_NUM
AND A.LEDGER=B.LEDGER)

If your query returns a row orrows, than you need to query the target table and make absolutely certain thatthe incoming row is a duplicate. Once that has been ascertained, you can safelydelete the row from the temp table. Your work isn't done yet, though, becauseall you've done so far is solve a problem that occurred with this particularprocess. To prevent the problem from occurring in the future, you need to goback to the source record and update a flag there. In the case of voucherposting, that means updating VOUCHER.POST_STATUS_AP to a value of "P"(an incorrect value of "U" is what caused the problem to begin with).You've already written a query to find the offending row, so you can fix theproblem at its source by adding a few lines to that query:

UPDATE PS_VOUCHER SETPOST_STATUS_AP='P' WHERE POST_STATUS_AP='U' AND (BUSINESS_UNIT,VOUCHER_ID) IN
(SELECTBUSINESS_UNIT,VOUCHER_ID FROM PS_VCHR_TEMP_LN11 A
WHERE EXISTS
(SELECT 'X' FROMPS_VCHR_ACCTG_LINE B
WHEREA.BUSINESS_UNIT=B.BUSINESS_UNIT
AND A.VOUCHER_ID=B.VOUCHER_ID
AND A.UNPOST_SEQ=B.UNPOST_SEQ
ANDA.APPL_JRNL_ID=B.APPL_JRNL_ID
ANDA.DST_ACCT_TYPE=B.DST_ACCT_TYPE
AND A.PYMNT_CNT=B.PYMNT_CNT
ANDA.VOUCHER_LINE_NUM=B.VOUCHER_LINE_NUM
ANDA.DISTRIB_LINE_NUM=B.DISTRIB_LINE_NUM
ANDA.DST_ACCT_TYPE=B.DST_ACCT_TYPE
ANDA.CF_BAL_LINE_NUM=B.CF_BAL_LINE_NUM
AND A.LEDGER=B.LEDGER))

Once you've got the problemresolved at its source, you can delete the record from the temp table andrestart the process, which should then complete successfully:

DELETE FROM PS_VCHR_TEMP_LN11 A
WHERE EXISTS
(SELECT 'X' FROMPS_VCHR_ACCTG_LINE B
WHEREA.BUSINESS_UNIT=B.BUSINESS_UNIT
AND A.VOUCHER_ID=B.VOUCHER_ID
AND A.UNPOST_SEQ=B.UNPOST_SEQ
ANDA.APPL_JRNL_ID=B.APPL_JRNL_ID
ANDA.DST_ACCT_TYPE=B.DST_ACCT_TYPE
AND A.PYMNT_CNT=B.PYMNT_CNT
AND A.VOUCHER_LINE_NUM=B.VOUCHER_LINE_NUM
ANDA.DISTRIB_LINE_NUM=B.DISTRIB_LINE_NUM
ANDA.DST_ACCT_TYPE=B.DST_ACCT_TYPE
ANDA.CF_BAL_LINE_NUM=B.CF_BAL_LINE_NUM
AND A.LEDGER=B.LEDGER)

There are also occasions inwhich there is no duplicate row in the target table and your query does notreturn any rows. In that case, the problem is usually the result of a bad joinbetween source tables that creates more than one row to insert. It could alsobe the result of a "GROUP BY" statement that summarizes data on thekey fields and one or two non-key fields, and there are two or more rows withdifferent non-key values but identical key values. In that case, you need tofigure out why one is different and correct it. Don't try adding that field asa key, though- you might solve today's problems, but you'll just be creatingheadaches further down the road.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
java.lang.LinkageError:loader constraint violation: when resolving method解释为加载器约束错误:在解析方法时。 当Java虚拟机(JVM)在运行时尝试加载类和解析类中的方法时,可能会遇到该错误。这通常发生在以下情况下: 1. 类型冲突:加载器尝试使用两个不同的类加载器加载具有相同名称但不同版本的类,从而导致了方法的冲突。因此,使用了不兼容的类定义。 2. 类重定义:加载器尝试重新定义已经在虚拟机中加载的类,从而导致加载的重复。这可能会导致类的冲突以及方法无法解析。 解决这个问题的方法如下: 1. 检查类加载器:确定是否有多个类加载器同时加载了相同的类。如果是,请确保只有一个类加载器加载相应的类。 2. 更新依赖关系:检查项目的依赖关系,确保所有的依赖项都是最新的版本并且兼容。 3. 清除类缓存:如果问题仍然存在,可以尝试清除JVM的类缓存。可以通过删除临时目录中的所有缓存文件来实现(例如,Java.io.tmpdir系统属性指向的目录)。 4. 更新JVM:确保使用的JVM是最新版本。有时,这种错误可能是由于JVM本身的问题引起的,而在较新的版本中可能已经修复。 总之,加载器约束错误是由于类加载器冲突或类重定义导致的,解决方法包括检查类加载器、更新依赖关系、清除类缓存以及更新JVM版本等。根据具体情况选择适当的解决方法。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值