Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Bases de datos > Firebird e Interbase
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 06-08-2015
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.706
Poder: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
A ver si te sirve:
Cita:
SCALED DATATYPES

Purpose
Use a scaled datatype to hold numbers with fixed size fractions.
Syntax
<scaled_type> ::=
{DECIMAL | NUMERIC} [(precision [, scale])]



Semantics
Firebird supports two scaled datatypes, NUMERIC and DECIMAL, for handling numeric data with a fixed decimal point, such as monetary values. You can specify optional precision and scale factors for both datatypes:
  • Precision is the total number or maximum number of digits, both significant and fractional, that can appear in a column of these datatypes. The allowable range for precision is from 1 to a maximum of 18.
  • Scale is the number of digits to the right of the decimal point that comprise the fractional portion of the number. The allowable range for scale is from zero to precision; in other words, scale must be less than or equal to precision.
NUMERIC and DECIMAL differ subtly in the way they handle numbers larger than the specified size. NUMERIC defines a datatype that holds a maximum of precision digits, whereas DECIMAL defines a datatype that holds at least that number of digits, and possibly more.
You can specify NUMERIC and DECIMAL datatypes without precision, in which case they are identical to INTEGER. The default value for scale is zero.
The below example declares a variable of type NUMERIC:
DECLARE a NUMERIC(5,3);



See also
INTEGER DATATYPE, FLOAT DATATYPE
Responder Con Cita
  #2  
Antiguo 06-08-2015
novato_erick novato_erick is offline
Miembro
 
Registrado: ago 2010
Ubicación: Panamá
Posts: 397
Poder: 17
novato_erick Va por buen camino
La teoria dice:

Cita:
Firebird es compatible con dos tipos de datos a escala, numeric y decimal, para el manejo de datos numéricos con un punto decimal fijo, como los valores monetarios

[color=#004465][font=Arial, sans-serif]

ok entiendo eso ya que lo encontre directamente aquí: http://www.janus-software.com/fbmanu...=psql&topic=30

sin embargo al hacer esto:
Código SQL [-]
IF (PCOMPRAPRODUCTO < NEW_COMPRA) THEN
  BEGIN     
      COMISIONCOMPRA = (NEW_COMPRA * COMISION)/100;  
      GASTOCOMPRA  = (NEW_COMPRA + COMISIONCOMPRA) * GASTOS /100;
      MARGENCOMPRA = (NEW_COMPRA + GASTOCOMPRA + MARGENCOMPRA)* MARGEN /100; 
      PVENTASINIVA = (COMISIONCOMPRA + GASTOCOMPRA + MARGENCOMPRA);
      SUBTOTALVENTA = NEW_COMPRA + PVENTASINIVA; 
      MONTOIVA = (SUBTOTALVENTA * PORCENTAJEIVA)/100;  
      PRECIOVENTACONIVA =  MONTOIVA + SUBTOTALVENTA; 

         UPDATE  PRECIO SET  PRECIOCOMPRA = :NEW_COMPRA,
                                       PRECIO_CIV = :PRECIOVENTACONIVA, --el valor que trae es null     
                                       PRECIO_SIV = :SUBTOTALVENTA,
                                       MONTO_IMPUESTO = :MONTOIVA
                               WHERE 
                               ID_PRECIO = :IDPRECIO;

Saludos
Responder Con Cita
  #3  
Antiguo 06-08-2015
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.706
Poder: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
No lo he mirado a fondo, apenas un vistazo, pero cambia el decimal por numeric en todos.
Responder Con Cita
  #4  
Antiguo 06-08-2015
novato_erick novato_erick is offline
Miembro
 
Registrado: ago 2010
Ubicación: Panamá
Posts: 397
Poder: 17
novato_erick Va por buen camino
Sip ya lo habia hecho en todo y nada aun me da el error


Saludos casimiro y disculpa la molestia..


novato_erick
Responder Con Cita
  #5  
Antiguo 06-08-2015
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.706
Poder: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
Pues cambia
COMISIONCOMPRA = 0.00
por
COMISIONCOMPRA = 0
Responder Con Cita
  #6  
Antiguo 06-08-2015
novato_erick novato_erick is offline
Miembro
 
Registrado: ago 2010
Ubicación: Panamá
Posts: 397
Poder: 17
novato_erick Va por buen camino
Ok encontré el problema:

tube que declarar las variables con un valor por defecto:

Código SQL [-]
as
DECLARE VARIABLE PRECIOVENTACONIVA NUMERIC(12, 2) DEFAULT 0

Esto solucionó el problema: aunque al inicializar mis variables en 0 al principio del post no se porque no tomaban ese valor si no es que estan definido en la declaración.

Extraño

pero Casimiro Gracias por tu aporte dejo este link que me ayudó a comprender cuando usar numeric y decimal:

https://firebird21.wordpress.com/201...ric-y-decimal/


Saludos a todos;
Responder Con Cita
  #7  
Antiguo 06-08-2015
novato_erick novato_erick is offline
Miembro
 
Registrado: ago 2010
Ubicación: Panamá
Posts: 397
Poder: 17
novato_erick Va por buen camino
casimiro no habia visto tu post anterior jajajajaja


pero nuevamente Gracias amigo


Saludos
Responder Con Cita
  #8  
Antiguo 06-08-2015
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.706
Poder: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
Para hacer cálculos deberías usar double, independientemente que luego lo guardes en un campo numeric.
Responder Con Cita
  #9  
Antiguo 06-08-2015
novato_erick novato_erick is offline
Miembro
 
Registrado: ago 2010
Ubicación: Panamá
Posts: 397
Poder: 17
novato_erick Va por buen camino
Te refieres a DOUBLE PRECISION en Firebird directamente?

porque en Delphi si mis variables son double.

Saludos
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

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
No se puede convertir variable de tipo null a tipo integer. JairoC Varios 5 30-11-2011 15:43:11
Error en tipo de variable astut Internet 6 25-02-2007 16:13:45
Como pasar la parte decimal de una variable maravert Varios 1 30-10-2006 20:30:11
Vble. tipo decimal silviodp Varios 2 11-05-2004 06:10:56
obtener el error que me envia SQL server jac000y MS SQL Server 2 12-01-2004 20:47:00


La franja horaria es GMT +2. Ahora son las 21:43:19.


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