Skip site navigation (1) Skip section navigation (2)

Re: isNumeric function?

From: Arguile <arguile(at)lucentstudios(dot)com>
To: Jerry LeVan <jerry(dot)levan(at)eku(dot)edu>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: isNumeric function?
Date: 2004-07-27 21:08:41
Message-ID: 1090962521.20911.13733.camel@broadswd.local (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Mon, 2004-07-26 at 09:52, Jerry LeVan wrote:
> Is there a (relatively) simple way to tell if a column
> is a "numeric" type other than comparing against the
> seven or so oids which may or may not be the complete
> list of things genererally considered to be numeric?
> I need this info to determine whether or not to justify
> left or right in a data display.

No, in fact it's more complicated than your example. You'd also want to
consider which type a domain maps down to. There really isn't anything
you can do to know if an extended type is a simple numeric (without
running a regex on all the output data -- which is beyond icky). For
formatting you'd probably not want to consider composite types or arrays
as numeric even if they're totally composed of a builtin numeric base

So, in addition to keeping a list of "pg_type.typname"s you consider
numeric, you'd also want UNION "pg_type.typbasetype" WHERE
"pg_type.typtype" = 'd' among some other restrictions.

See for
more info.

As you said this was in an application, your DB driver may automatically
map output types to SQL defined ones. If this is the case you might
consider just relying on your driver's mapping.

In response to

pgsql-general by date

Next:From: Jerry LeVanDate: 2004-07-27 21:13:20
Subject: Aborting long running command.
Previous:From: ArguileDate: 2004-07-27 20:36:48
Subject: Re: Trigger on Postgres for tables syncronization

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group