今天在改一个维护单时候遇到如下问题,纠结许久,经各种排查原来是由于Oracle中Number定义的长度不够导致。
问题情景是在调用存储过程时候:
call SP_GL_CLOSE_PERIOD_CHECK('2014','440199','1','10110',12)
报错,之前一直好使的存储过程突然出错,很茫然。无奈查找存储过程,最终问题定位到如下sql:
而直接sql查询执行查询如下
可以看出其VTEMP2的结果长度明显大于10。而经查资料Oracle中Number数据类型如下
number数据类型
number类型的语法很简单:number(p,s):
p:精度位,precision,是总有效数据位数,取值范围是38,默认是38,可以用字符*表示38。
s:小数位,scale,是小数点右边的位数,取值范围是-84~127,默认值取决于p,如果没有指定p,那么s是最大范围,如果指定了p,那么s=0。
p:isthe precision,or the total number of digits. Oracle guarantees the portabilityof numbers with precision ranging from 1 to 38.
s:isthe scale, or the number of digits to the right of the decimal point. The scalecan range from -84 to 127.
查找到原因之后,修改就简单了,把vTemp2 number(10,2);改为vTemp2 number(30,2);即可