From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Henry Drexler <alonup8tb(at)gmail(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: opposite of chr(int) |
Date: | 2011-10-06 21:23:29 |
Message-ID: | CAHyXU0z0D63pGODHpBn7gt5fkWLxRYGAZG=UhJTMOvTxaCzK1Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Thu, Oct 6, 2011 at 2:42 PM, Henry Drexler <alonup8tb(at)gmail(dot)com> wrote:
> 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
I think the regex approach is better, but for posterity there is a
reverse of chr() function -- ascii();
postgres=# select ascii('C');
ascii
-------
67
(1 row)
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Henry Drexler | 2011-10-06 21:49:06 | Re: opposite of chr(int) |
Previous Message | Henry Drexler | 2011-10-06 21:19:17 | Re: opposite of chr(int) |