Heim  >  Artikel  >  Datenbank  >  ORA-06502: PL/SQL: 数字或值错误 : 字符串缓冲区太小 错误分析

ORA-06502: PL/SQL: 数字或值错误 : 字符串缓冲区太小 错误分析

WBOY
WBOYOriginal
2016-06-07 17:17:394236Durchsuche

最近在进行oracle的一些操作时,总会遇到这个错误: ORA-06502: PL/SQL: 数字或值错误 : 字符串缓冲区太小,错误如下:

1. 问题起因

最近在进行Oracle的一些操作时,总会遇到这个错误:  ORA-06502: PL/SQL: 数字或值错误 :  字符串缓冲区太小,错误如下:

2.官方解释

查看官方文档上的解释:

ORA-06502: PL/SQL: numeric or value errorstring

Cause: An arithmetic, numeric, string, conversion, or constraint error occurred. For example, this error occurs if an attempt is made to assign the value NULL to a variable declared NOT NULL, or if an attempt is made to assign an integer larger than 99 to a variable declared NUMBER(2).

Action: Change the data, how it is manipulated, or how it is declared so that values do not violate constraints.

官方解释是:  想存入数据库的数据(包含数据,字符串等等)不符合该字段的定义(比如长度,约束等), 举个例子,就是说你想存一个空值到非空字段,如存入3位以上的数字到NUMBER(2)字段中,等等

官方解决方法是: 改变数据的类型,或长度,等等。


3. 问题描述

但是,实际中,我们在做升级的时候,或者做EXPDP/IMPDP的时候,根本不是我们本身的业务数据,,也会报这个错误,遇到这种情况,我怎么知道去哪改这个数据呢,

举几个例子:

例1. 上次在做oracle升级的时候,从11.2.0.1.0升到11.2.0.1.6的时候在跑最后的升级脚本catcpu.sql的时候,就遇到这个错误:

这种情况下,明明是oracle本身的东西出了错,我们无法去改变任何东西。


例2: 在做expdp/impdp 导出导入的时候,报这个错:

这种情况下,貌似是oracle在创建这个任务的时候,因为ORA-06502错误无法创建。



4.问题解决

以上两种情况,和用户数据无关,但出了ORA-06502错误,说明ORACLE本身有一张系统表在插入数据的时候不符合长短需求,而报了这个错。

搜集信息:经查资料, oracle有一个隐含参数“_system_trig_enabled”用来控制系统触发器的,用来存储系统的一些触发事件,但这个表(目前不知道是哪个表)本身有问题,导致数据无法插入。

解决思路: 顺着这个想法,只要我们把这个参数关掉,让系统的日志不保存在那张有问题的表中,就好了(当然有隐含风险,目前未知):

解决方法

更改之后,再做上述操作,问题解决


5.总结

根据问题的不同有2种解决方法

一.如果是用户数据,则更改用户表,或者数据

二.如果是oracle系统表,则使用如下语句关系统系统触发器:

alter system set "_system_trig_enabled"=false;

linux

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn