pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Halley Pacheco de Oliveira <halleypo@yahoo.com.br>
To: pgsql-sql@postgresql.org
Cc: tv@fuzzy.cz
Subject: Re: converting varchar to integer
Date: Wed, 17 Aug 2005 07:46:05 -0300 (ART)
Message-ID: <20050817104605.76269.qmail@web52703.mail.yahoo.com> (raw)

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/ 



view thread (7+ messages)  latest in thread

Message-ID: <20050817104605.76269.qmail@web52703.mail.yahoo.com>
Permalink:  ../20050817104605.76269.qmail@web52703.mail.yahoo.com/
Also on:    postgresql.org/message-id/20050817104605.76269.qmail@web52703.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: halleypo@yahoo.com.br, tv@fuzzy.cz
  Subject: Re: converting varchar to integer
  In-Reply-To: <20050817104605.76269.qmail@web52703.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox