Re: [despammed] converting varchar to integer - Mailing list pgsql-sql

From Kretschmer Andreas
Subject Re: [despammed] converting varchar to integer
Date
Msg-id 20050817093029.GA1647@kaufbach.delug.de
Whole thread Raw
In response to converting varchar to integer  (tv@fuzzy.cz)
Responses Re: [despammed] converting varchar to integer
List pgsql-sql
tv@fuzzy.cz <tv@fuzzy.cz> schrieb:

> Hi,
> 
>    I have a varchar column, and I need to
> 
>    1) check the value in it is an integer
>    2) get the integer value (as integer)
> 
>    The problem is I can't suppose the're only correct
>    values - ie there can be something like 'xssdkjsd',
>    '230kdd' or even an empty string etc.

test=# select * from foo; t   | n
------+---bla  |bla1 |2    |
(3 rows)

test=# update foo set n = substring(t , '[0-9]')::int;
UPDATE 3
test=# select * from foo; t   | n
------+---bla  |bla1 | 12    | 2
(3 rows)


Regards, Andreas
-- 
Diese Message wurde erstellt mit freundlicher Unterstützung eines freilau-
fenden Pinguins aus artgerechter Freilandhaltung.   Er ist garantiert frei
von Micro$oft'schen Viren. (#97922 http://counter.li.org)     GPG 7F4584DA
Was, Sie wissen nicht, wo Kaufbach ist? Hier: N 51.05082°, E 13.56889° ;-)


pgsql-sql by date:

Previous
From: Josh Berkus
Date:
Subject: Re: converting varchar to integer
Next
From: Halley Pacheco de Oliveira
Date:
Subject: Re: converting varchar to integer