Re: Conversion of string to int using digits at beginning
| От | Raymond O'Donnell |
|---|---|
| Тема | Re: Conversion of string to int using digits at beginning |
| Дата | |
| Msg-id | 4923008C.6060602@iol.ie обсуждение исходный текст |
| Ответ на | Conversion of string to int using digits at beginning ("Andrus" <kobruleht2@hot.ee>) |
| Ответы |
Re: Conversion of string to int using digits at beginning
Re: Conversion of string to int using digits at beginning |
| Список | pgsql-general |
On 18/11/2008 17:33, Andrus wrote:
> create temp table test (test char(20));
> insert into test values ('12');
> insert into test values ('23/3');
> insert into test values ('AX/3');
> select max(test::int) from test;
>
> but got
>
> ERROR: invalid input syntax for integer: "23/3 "
>
> How to fix this so that this query returns 23 without error ?
It's not a question of "fixing" - it's not broken! :-)
You could use a regular expression in substring() to get just the
numeric bits.
Ray.
------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------
В списке pgsql-general по дате отправления: