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,'990') END AS
number FROM test;;
number
123
123
Tomas,
>I've written two on my own (see the functions below),
>but maybe there's something faster?
Nope. 'cept I'd combine those two functions into a single function that
returns NULL if the value isn't an integer.
--
--Josh
Josh Berkus
Aglio Database Solutions
San Francisco
---