From: | William Leite Araújo <william(dot)bh(at)gmail(dot)com> |
---|---|
To: | "Laurent Martelli" <laurent(dot)martelli(at)seditel(dot)fr> |
Cc: | "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>, "Laurent Martelli" <lmartelli(at)seditel(dot)fr>, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #3506: to_number silently ignore characters |
Date: | 2007-08-03 14:55:03 |
Message-ID: | bc63ad820708030755s7ab28051i63b4dc64b5db9e5c@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Ok. Now the function is OK....
CREATE OR REPLACE FUNCTION my_to_number(text,text) RETURNS numeric AS
$$
BEGIN
IF NOT textregexeq($1,'^[0-9]+$') THEN
RAISE EXCEPTION 'TEXT % is not a valid NUMBER',$1;
END IF;
RETURN to_number($1,$2);
END;
$$ LANGUAGE PLPGSQL IMMUTABLE;
Tests...
=# select my_to_number('123.0','999999');
ERRO: TEXT 123.0 is not a valid NUMBER
=# select my_to_number('1230','999999');
my_to_number
--------------
1230
(1 registro)
Tempo: 0,734 ms
--
William Leite Araújo
DBA - QualiConsult
From | Date | Subject | |
---|---|---|---|
Next Message | Rodriguez Fernando | 2007-08-03 14:56:43 | Re: Bug Pgsql |
Previous Message | William Leite Araújo | 2007-08-03 14:48:49 | Re: BUG #3506: to_number silently ignore characters |