Re: Comprobar que un numeric tenga decimales.

From: "Beto Guerrero" <guerrero(dot)beto(at)gmail(dot)com>
To: "conrado(at)mapfre(dot)com(dot)ar" <conrado(at)mapfre(dot)com(dot)ar>
Cc: listapostgres(at)hotmail(dot)com, systemguards(at)gmail(dot)com, pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Comprobar que un numeric tenga decimales.
Date: 2006-10-09 20:37:46
Message-ID: cbb40a720610091337m4f5e3024t6e90d445af64d2bb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

podrias usar algo asi:

select case when position('.' in campo)=0 then 'No' else 'Si' end as
decimal from tabla

El 9/10/06, conrado(at)mapfre(dot)com(dot)ar<conrado(at)mapfre(dot)com(dot)ar> escribió:
> Podrías verificar el resultado de la condicion.
>
> si tu_valor = trunc(tu_valor) entonces
> sin decimales
> sino
> con decimales
>
>
> > -----Mensaje original-----
> > De: listapostgres(at)hotmail(dot)com [mailto:listapostgres(at)hotmail(dot)com]
> > Enviado el: Lunes, 09 de Octubre de 2006 05:23 p.m.
> > Para: systemguards(at)gmail(dot)com
> > CC: pgsql-es-ayuda(at)postgresql(dot)org
> > Asunto: Re: [pgsql-es-ayuda] Comprobar que un numeric tenga decimales.
> >
> >
> > Gracias por responder, pero esas funciones solo me permiten
> > obtener un
> > valor, me explico, yo necesito saber si el resultado de una operacion
> > resulta decimal o no.
> > Por ejemplo:
> >
> > result numeric;
> > oper1 numeric;
> > oper2 numeric;
> >
> > result = oper1 + oper2;
> >
> > 1 + 1 = 2 ----> Valor entero
> > 1.5 + 1 = 2.5 -----> Valor Decimal
> >
> > Y el resultado se almacena en la misma variable
> >
> > Ahora bien, como saber si el resultado contiene decimales, o
> > si la parte
> > decimal es "0"?
> >
> > Gracias, espero haberme explicado mejor. :)
> > Zule
> >
> >
> >
> > >From: "Jaime Casanova" <systemguards(at)gmail(dot)com>
> > >To: "listapostgres(at)hotmail(dot)com" <listapostgres(at)hotmail(dot)com>
> > >CC: pgsql-es-ayuda(at)postgresql(dot)org
> > >Subject: Re: [pgsql-es-ayuda] Comprobar que un numeric tenga
> > decimales.
> > >Date: Mon, 9 Oct 2006 15:13:48 -0500
> > >
> > >On 10/9/06, listapostgres(at)hotmail(dot)com
> > <listapostgres(at)hotmail(dot)com> wrote:
> > >>Hola lista!
> > >>
> > >>Como podria saber si un dato de tipo numeric posee decimales?
> > >>La razon es la siguiente, yo realizo un calculo en donde el
> > resultado
> > >>algunas veces podria resultar con decimales, pero en otras
> > ocasiones el
> > >>resultado es entero (esto es porque en una tabla existen datos con
> > >>decimales
> > >>y otros sin ello, lo que al sumar un entero con un entero
> > me resulta un
> > >>entero, pero al sumar un decimal con un entero u otro
> > decimal resulta un
> > >>decimal).
> > >>
> > >
> > >puedes usar una de las funciones siguentes segun te convenga:
> > >
> > >- ceil(numeric)
> > >- floor(numeric)
> > >- round(numeric)
> > >- trunc(numeric)
> > >
> > >http://www.postgresql.org/docs/8.1/static/functions-math.html
> > >
> > >--
> > >Atentamente,
> > >Jaime Casanova
> > >
> > >"Programming today is a race between software engineers striving to
> > >build bigger and better idiot-proof programs and the universe trying
> > >to produce bigger and better idiots.
> > >So far, the universe is winning."
> > > Richard Cook
> > >
> > >---------------------------(fin del
> > mensaje)---------------------------
> > >TIP 7: no olvides aumentar la configuración del "free space map"
> >
> > _________________________________________________________________
> > Un amor, una aventura, compañía para un viaje. Regístrate
> > gratis en MSN Amor
> > & Amistad. http://match.msn.es/match/mt.cfm?pg=channel&tcid=162349
> >
> >
> > ---------------------------(fin del
> > mensaje)---------------------------
> > TIP 4: No hagas 'kill -9' a postmaster
> >
>
> ---------------------------(fin del mensaje)---------------------------
> TIP 5: ¿Has leído nuestro extenso FAQ?
>
> http://www.postgresql.org/files/documentation/faqs/FAQ.html
>

--

Atte

Alberto Nicolas Guerrero P.
Desarrollador Java / Open Source
Tel: +51.15331720
Cel: +51.197208984

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message listapostgres 2006-10-09 21:08:33 Re: Comprobar que un numeric tenga decimales.
Previous Message conrado 2006-10-09 20:30:17 RE: Comprobar que un numeric tenga decimales.