Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Conexión con bases de datos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Conexión con bases de datos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 15-12-2008
nugame nugame is offline
Miembro
 
Registrado: may 2003
Posts: 50
Poder: 21
nugame Va por buen camino
error numeric overflow con applyupdates

Hola:

Utilizo applyupdates en un programa de facturas.
Todo bien hasta que en la línea de factura pongo una cantidad de 300000 y al aplicar al applyupdates me da el siguiente error..:

Dynamic SQL error SQL error code= -303
arithmetic exception , numeric overflow , or string truncation

Solo me pasa al llegar a esas cantidades. Si no utilizo el applyupdates todo bien.

¿Hay un límite de memoria o algo?

Gracias
Responder Con Cita
  #2  
Antiguo 15-12-2008
nugame nugame is offline
Miembro
 
Registrado: may 2003
Posts: 50
Poder: 21
nugame Va por buen camino
Error solucionado..

Perdonar pero el error no está en el applyupdates está en que usé un campo decimal(9,4) y produce el overflow...

Un saludo
Responder Con Cita
  #3  
Antiguo 15-12-2008
Avatar de xEsk
[xEsk] xEsk is offline
Miembro Premium
 
Registrado: feb 2006
Posts: 454
Poder: 19
xEsk Va por buen camino
Hace no mucho, esto me paso pero con enteros, yo enviaba un Int64, y en la BD el formato era Int32, y me generaba este mismo error... La solución era evidente, cambiar a Int64 el campo de la BD.

Información sobre el error.

Cita:
2. Arithmetic overflow

If you use fixed precision datatypes (smallint, integer, bigint, decimal and numeric), it is possible that the result of calculation doesn't fit the datatype. Try casting the values in complex expressions as double precision and see whether the error goes away. If it works and you don't care about being too precise, you can leave it at that. Otherwise you need to check every operation and calculate the result.

Here's an example: if you multiply 9.12 with 8.11 (both numeric(18,2)) you would get 73.9632. If Firebird would store that into numeric(18,2) datatype, we would lose 0.0032. Doesn't look much, but when you have complex calculations, you can easily loose thousands (dollars or euros). Therefore, the result is stored in numeric(18,4).

Problems are rarely seen with such low precision as 2. Let's use some bigger precision. For example, numeric(18,6) times numeric(18,6) yields numeric(18,12) result, meaning that maximal value it can store is 9223372.036854775807. If (for example) you wish to keep only 6 digits of precision, you could use something like:

cast(value1 as numeric(18,3)) * cast(value2 as numeric(18,3))

which would yield numeric(18,6) result, but it is quite possible that you would get more accurate result by casting to double:

cast(cast(value1 as double precision) * cast(value2 as double precision) as numeric(18,6))


Also, if you have mixed multiplications and divisions it helps to change the order of operations, so that the overflow doesn't happen.
Saludos.
Responder Con Cita
  #4  
Antiguo 15-12-2008
nugame nugame is offline
Miembro
 
Registrado: may 2003
Posts: 50
Poder: 21
nugame Va por buen camino
Sobre el overflow..

Hola:

Lo que me pasó es que hace tiempo que programé esta aplicación y no se me ocurrió mejor forma que poner el campo como un DECIMAL(9,4).
Con un float seria mejor, o se cambio a un DECIMAL(10,4) se me queda resuelto.

Gracias por tu hilo..

Un saludo
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
float a decimal: overflow error sinalocarlos MS SQL Server 4 31-10-2006 18:53:17
Aritmetic excepcion, numeric overflow... andressanchez Firebird e Interbase 10 27-04-2006 15:40:56
Error: arithmetic exception, numeric overflow, or string truncation burasu Conexión con bases de datos 3 22-09-2005 15:48:29
Error: BCD Overflow bismarck_sierra Conexión con bases de datos 2 20-06-2004 01:34:44
Error ApplyUpdates(0); raulparraco Conexión con bases de datos 4 27-05-2003 22:43:44


La franja horaria es GMT +2. Ahora son las 14:40:04.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi