Re: CHAR to INT

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: Martín Marqués <martin(dot)marques(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: CHAR to INT
Date: 2008-07-12 13:46:59
Message-ID: 162867790807120646u5d20c53crdc9a75959d06f9f7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello

2008/7/12 Martín Marqués <martin(dot)marques(at)gmail(dot)com>:
> I'm trying to make a PL function to pass from an alphanumeric string
> to a numeric one changing the chars in the string to it's ORD (the
> inverse of the chr function) and I'm stumbling with two problems:
>
> 1) How to know if the CHAR is numeric or not.
> 2) If it's not numeric I want to get it's ord, but I can't find
> something like that in PG.
>
postgres=# select '1' between '0' and '9';
?column?
----------
t
(1 row)

postgres=# select 'a' between '0' and '9';
?column?
----------
f
(1 row)

postgres=# select ascii('7') - ascii('0');
?column?
----------
7
(1 row)

Regards
Pavel Stehule

> Any ideas?
>
> --
> Martín Marqués
> select 'martin.marques' || '@' || 'gmail.com'
> DBA, Programador, Administrador
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

  • CHAR to INT at 2008-07-12 13:15:29 from Martín Marqués

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Martín Marqués 2008-07-12 14:01:17 Re: CHAR to INT
Previous Message Scott Marlowe 2008-07-12 13:19:08 Re: Rollback in Postgres