简体   繁体   English

获取ORA-06502:PL / SQL:数字或值错误:SQL触发器中的字符到数字转换错误

[英]Getting ORA-06502: PL/SQL: numeric or value error: character to number conversion error in SQL trigger

I'm getting below error in the web methods adapter on the table which has the MIH_TRIGGER. 我在具有MIH_TRIGGER的表上的Web方法适配器中遇到以下错误。

(65000/6502) ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at "B2B_OPS_BUILD_ADMIN.MIH_TRIGGER", line 2 ORA-04088: error during execution of trigger 'B2B_OPS_BUILD_ADMIN.MIH_TRIGGER' (65000/6502)ORA-06502:PL / SQL:数字或值错误:字符到数字的转换错误ORA-06512:在“ B2B_OPS_BUILD_ADMIN.MIH_TRIGGER”,第2行ORA-04088:执行触发器“ B2B_OPS_BUILD_ADMIN.MIH_TRIGGER”时出错

Below is the MIH_TRIGGER fore reference which will update the data from OPS_BUILD_MIH table to OPS_BUILD_AUDITLOG table whenever OFFSET column is updated. 以下是MIH_TRIGGER的前参考,每当OFFSET列更新时,该参考就会将数据从OPS_BUILD_MIH表更新到OPS_BUILD_AUDITLOG表。

The OFFSET column in OPS_BUILD_MIH is NUMBER OPS_BUILD_MIH中的OFFSET列为NUMBER

The OLD_VALUE and NEW_VALUE columns in OPS_BUILD_AUDITLOG are VARCHAR2(100). OPS_BUILD_AUDITLOG中的OLD_VALUE和NEW_VALUE列为VARCHAR2(100)。

I'm trying to insert a numeric value which is in OFFSET column into the OLD_VALUE and NEW_VALUE varchar2 columns and getting this error. 我试图在OLD_VALUE和NEW_VALUE varchar2列中插入OFFSET列中的数值,并得到此错误。

create or replace TRIGGER "B2B_OPS_BUILD_ADMIN"."MIH_TRIGGER" 
AFTER UPDATE OF OFFSET
ON OPS_BUILD_MIH
FOR EACH ROW
BEGIN
 if ( nvl(:OLD.OFFSET,'xYz#@!0') != nvl(:NEW.OFFSET,'xYz#@!0')) then
  INSERT INTO OPS_BUILD_AUDITLOG
    (TABLE_NAME,
     COLUMN_NAME,
     OLD_VALUE,
     NEW_VALUE,
     UPDATED_BY,
     UPDATED_DTM,
     UUID)
  VALUES  
    ('OPS_BUILD_MIH',
     'OFFSET',
     :OLD.OFFSET,
     :NEW.OFFSET,
     :NEW.LAST_UPDATED_BY,
     :NEW.LAST_UPDATED_DTM,
     :OLD.MIH_ID);
 end if;

END; 

Can you please suggest a fix for this so that I can modify the above trigger accordingly. 您能否为此提出建议,以便我可以相应地修改上述触发器。

Appreciate your help in advance. 提前感谢您的帮助。

Regards Phani 问候帕尼

As Gaj has already pointed out, the issue lies with your NVL - you're trying to compare a non-numeric string to a number, which won't work. 正如Gaj所指出的那样,问题出在您的NVL上-您试图将非数字字符串与数字进行比较,这是行不通的。

Whilst you could change the NVL to check for a numeric value you will never encounter, it would be far better to change the condition to: 尽管您可以更改NVL来检查您永远不会遇到的数值,但是最好将条件更改为:

:OLD.OFFSET != :NEW.OFFSET
or (:OLD.OFFSET is not null and :NEW.OFFSET is null)
or (:OLD.OFFSET is null and :NEW.OFFSET is not null)

That way, you don't have to make up a magic number that your actual values could never be; 这样,您就不必组成一个实际数值永远不可能达到的幻数; assuming such a number even exists! 假设这个数字甚至存在!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ORA-06502 PL / SQL:数字或值错误:字符到数字的转换错误; - ORA-06502 PL/SQL: numeric or value error: character to number conversion error; SQL错误:ORA-06502:PL / SQL:数字或值错误 - SQL Error: ORA-06502: PL/SQL: numeric or value error 奇怪的ORA-06502:PL / SQL:数字或值错误 - Strange ORA-06502: PL/SQL: numeric or value error ORA-06502: PL/SQL: 连接时出现数字或值错误 - ORA-06502: PL/SQL: numeric or value error when concatenating ORA-06502:PL / SQL:数字或值错误:Oracle SQL查询中的字符串缓冲区太小 - ORA-06502: PL/SQL: numeric or value error: character string buffer too small in Oracle sql query Oracle数据库错误:ORA-06502:PL / SQL:数字或值错误:字符串缓冲区太小 - Oracle Database Error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06502:PL/SQL:数字或值错误:字符串缓冲区太小 - ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06502:PL/SQL:数字或值错误:字符串缓冲区太小,只有三个数字 - ORA-06502: PL/SQL: numeric or value error: character string buffer too small only three numbers ORA-06502: PL/SQL: 数字或值错误: 字符串缓冲区太小: 构建时 model - ORA-06502: PL/SQL: numeric or value error: character string buffer too small: When building a model ORA-06502:PL / SQL:数字或值错误:数字精度太大 - ORA-06502: PL/SQL: numeric or value error: number precision too large
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM