ORA-01438: 值大于此列允许的指定精度

发布于 2024-07-08 00:22:15 字数 617 浏览 9 评论 0原文

有时,我们会从合作伙伴的数据库中收到以下错误:

<i>ORA-01438: value larger than specified precision allows for this column</i>

完整响应如下所示:

<?xml version="1.0" encoding="windows-1251"?>
<response>
  <status_code></status_code>
  <error_text>ORA-01438: value larger than specified precision allows for this column ORA-06512: at &quot;UMAIN.PAY_NET_V1_PKG&quot;, line 176 ORA-06512: at line 1</error_text>
  <pay_id>5592988</pay_id>
  <time_stamp></time_stamp>
</response>

导致此错误的原因是什么?

We get sometimes the following error from our partner's database:

<i>ORA-01438: value larger than specified precision allows for this column</i>

The full response looks like the following:

<?xml version="1.0" encoding="windows-1251"?>
<response>
  <status_code></status_code>
  <error_text>ORA-01438: value larger than specified precision allows for this column ORA-06512: at "UMAIN.PAY_NET_V1_PKG", line 176 ORA-06512: at line 1</error_text>
  <pay_id>5592988</pay_id>
  <time_stamp></time_stamp>
</response>

What can be the cause for this error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

∞梦里开花 2024-07-15 00:22:15

您尝试存储的数字对于该字段来说太大了。 查看规模和精度。 两者之间的区别在于可以存储的小数点前面的位数。

select cast (10 as number(1,2)) from dual
             *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column

select cast (15.33 as number(3,2)) from dual
             *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column

低端的任何内容都会被截断(默默地)

select cast (5.33333333 as number(3,2)) from dual;
CAST(5.33333333ASNUMBER(3,2))
-----------------------------
                         5.33

The number you are trying to store is too big for the field. Look at the SCALE and PRECISION. The difference between the two is the number of digits ahead of the decimal place that you can store.

select cast (10 as number(1,2)) from dual
             *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column

select cast (15.33 as number(3,2)) from dual
             *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column

Anything at the lower end gets truncated (silently)

select cast (5.33333333 as number(3,2)) from dual;
CAST(5.33333333ASNUMBER(3,2))
-----------------------------
                         5.33
兔小萌 2024-07-15 00:22:15

该错误似乎不是字符字段之一,而更多是数字字段。 (如果是像 WW 提到的字符串问题,您会得到“值太大”或类似的信息。)可能您使用的数字超出了允许的范围,例如定义为数字的列中的 1,000000001 (10,2 )。

查看 WW 提到的源代码,找出可能导致问题的列。 然后检查那里正在使用的数据(如果可能)。

The error seems not to be one of a character field, but more of a numeric one. (If it were a string problem like WW mentioned, you'd get a 'value too big' or something similar.) Probably you are using more digits than are allowed, e.g. 1,000000001 in a column defined as number (10,2).

Look at the source code as WW mentioned to figure out what column may be causing the problem. Then check the data if possible that is being used there.

氛圍 2024-07-15 00:22:15

除了前面的答案之外,您应该注意,定义为 VARCHARS(10) 的列将存储 10 个字节,而不是 10 个字符,除非您将其定义为 VARCHAR2(10 CHAR)

[OP 的问题似乎是数字相关...这只是为了防止其他人有类似的问题]

Further to previous answers, you should note that a column defined as VARCHARS(10) will store 10 bytes, not 10 characters unless you define it as VARCHAR2(10 CHAR)

[The OP's question seems to be number related... this is just in case anyone else has a similar issue]

青芜 2024-07-15 00:22:15

这表明您正在尝试将太大的内容放入列中。 例如,您有一个 VARCHAR2(10) 列,并且您要输入 11 个字符。 数字也是如此。

这发生在 UMAIN 包的第 176 行。 你需要去看看它,看看它是做什么的。 希望您可以在源代码管理中(或从 user_source )查找它。 Oracle 的更高版本更好地报告此错误,告诉您哪个列和什么值。

This indicates you are trying to put something too big into a column. For example, you have a VARCHAR2(10) column and you are putting in 11 characters. Same thing with number.

This is happening at line 176 of package UMAIN. You would need to go and have a look at that to see what it is up to. Hopefully you can look it up in your source control (or from user_source). Later versions of Oracle report this error better, telling you which column and what value.

不顾 2024-07-15 00:22:15

供参考:
数字字段大小违规将给出
ORA-01438: 值大于此列允许的指定精度

VARCHAR2 字段长度违规将给出
ORA-12899: 列的值太大...

Oracle 根据错误代码和消息来区分列的数据类型。

FYI:
Numeric field size violations will give
ORA-01438: value larger than specified precision allowed for this column

VARCHAR2 field length violations will give
ORA-12899: value too large for column...

Oracle makes a distinction between the data types of the column based on the error code and message.

叹沉浮 2024-07-15 00:22:15

我遇到的一个非常棘手的问题是,描述列属性的 OCI 调用的行为因 Oracle 版本而异。 描述在没有任何 prec 或小数位数的情况下创建的简单 NUMBER 列在 9i、10g 和 11g 上返回差异

One issue I've had, and it was horribly tricky, was that the OCI call to describe a column attributes behaves diffrently depending on Oracle versions. Describing a simple NUMBER column created without any prec or scale returns differenlty on 9i, 1Og and 11g

长发绾君心 2024-07-15 00:22:15

来自 http://ora-01438.ora-code.com/ (权威资源Oracle 支持之外):

ORA-01438:值大于此列允许的指定精度
原因:插入或更新记录时,输入的数值超出了为列定义的精度。
操作:输入符合数字列精度的值,或使用 MODIFY 选项和 ALTER TABLE 命令来扩展精度。

http://ora-06512.ora-code.com/

ORA -06512:在字符串行
原因:堆栈因未处理的异常而展开时出现回溯消息。
操作:修复导致异常的问题或为此情况编写异常处理程序。 或者您可能需要联系您的应用程序管理员或 DBA。

From http://ora-01438.ora-code.com/ (the definitive resource outside of Oracle Support):

ORA-01438: value larger than specified precision allowed for this column
Cause: When inserting or updating records, a numeric value was entered that exceeded the precision defined for the column.
Action: Enter a value that complies with the numeric column's precision, or use the MODIFY option with the ALTER TABLE command to expand the precision.

http://ora-06512.ora-code.com/:

ORA-06512: at stringline string
Cause: Backtrace message as the stack is unwound by unhandled exceptions.
Action: Fix the problem causing the exception or write an exception handler for this condition. Or you may need to contact your application administrator or DBA.

撧情箌佬 2024-07-15 00:22:15

定义如下变量可能是一个好习惯:

v_departmentid departments.department_id%TYPE;

而不是如下:

v_departmentid NUMBER(4)

It might be a good practice to define variables like below:

v_departmentid departments.department_id%TYPE;

NOT like below:

v_departmentid NUMBER(4)
守护在此方 2024-07-15 00:22:15

如果您使用 PHP 并绑定整数变量(oci_bind_by_name 和 SQLT_INT),也可能会收到此错误代码。
如果您尝试通过绑定变量插入 NULL,则会出现此错误,或者有时会插入值 2(这更糟糕)。

要解决此问题,您必须将变量绑定为固定长度的字符串 (SQLT_CHR)。 在插入之前,必须将 NULL 转换为空字符串(等于 Oracle 中的 NULL),并且所有其他整数值必须转换为其字符串表示形式。

It is also possible to get this error code, if you are using PHP and bound integer variables (oci_bind_by_name with SQLT_INT).
If you try to insert NULL via the bound variable, then you get this error or sometimes the value 2 is inserted (which is even more worse).

To solve this issue, you must bind the variable as string (SQLT_CHR) with fixed length instead. Before inserting NULL must be converted into an empty string (equals to NULL in Oracle) and all other integer values must be converted into its string representation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文