Re: converting varchar to integer

From: Halley Pacheco de Oliveira <halleypo(at)yahoo(dot)com(dot)br>
To: pgsql-sql(at)postgresql(dot)org
Cc: tv(at)fuzzy(dot)cz
Subject: Re: converting varchar to integer
Date: 2005-08-17 10:46:05
Message-ID: 20050817104605.76269.qmail@web52703.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Using CASE to avoid '':

CREATE TABLE test (number TEXT);
INSERT INTO test VALUES('123');
INSERT INTO test VALUES('a123b');
INSERT INTO test VALUES('');
teste=> SELECT CASE number WHEN '' THEN NULL ELSE to_number(number,'999999999999990') END AS
number FROM test;;
number
--------
123
123

(3 lines)

__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger
http://br.download.yahoo.com/messenger/

Browse pgsql-sql by date

  From Date Subject
Next Message Frank Bax 2005-08-17 16:46:01 Re: [despammed] converting varchar to integer
Previous Message Kretschmer Andreas 2005-08-17 09:30:29 Re: [despammed] converting varchar to integer