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

opposite of chr(int)

From: Henry Drexler <alonup8tb(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: opposite of chr(int)
Date: 2011-10-06 19:42:31
Message-ID: CAAtgU9RKaT9WQhhZAcMoqJG0rxL-gudB=CwUUOnxORmwuWub=w@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
Looking at the string functions on:
http://www.postgresql.org/docs/9.0/static/functions-string.html

I only see chr(int) and not something like int(chr).

reading through the others on that page i do not see a int(chr)

the goal is to tell whether or not a character in a string is an integer or
not

my current workaround is this:

select
case
when substring('wallawa9kl',8,1) = '0' then 'true'
when substring('wallawa9kl',8,1) = '1' then 'true'
when substring('wallawa9kl',8,1) = '2' then 'true'
when substring('wallawa9kl',8,1) = '3' then 'true'
when substring('wallawa9kl',8,1) = '4' then 'true'
when substring('wallawa9kl',8,1) = '5' then 'true'
when substring('wallawa9kl',8,1) = '6' then 'true'
when substring('wallawa9kl',8,1) = '7' then 'true'
when substring('wallawa9kl',8,1) = '8' then 'true'
when substring('wallawa9kl',8,1) = '9' then 'true'
else 'false'
end


just wondering if there is something more compact or if this is an okay
workaround solution.

Responses

pgsql-novice by date

Next:From: Gary ChambersDate: 2011-10-06 20:15:41
Subject: Re: opposite of chr(int)
Previous:From: Tony TheodoreDate: 2011-10-06 08:49:54
Subject: Re: Using regoper type with OPERATOR()

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