Re: Re: [BUGS] Unnexpected results using to_number() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Re: [BUGS] Unnexpected results using to_number()
Date
Msg-id 124.963238366@sss.pgh.pa.us
Whole thread Raw
In response to Re: Re: [BUGS] Unnexpected results using to_number()  (Karel Zak <zakkr@zf.jcu.cz>)
List pgsql-hackers
Karel Zak <zakkr@zf.jcu.cz> writes:
>> What do you think about raising an error instead of returning NULL?

> Oracle:
> SVRMGR> select to_number('12,454.8-', '') from dual;
> TO_NUMBER(
> ----------
> ORA-01722: invalid number

> I mean that we can use ERROR here too. My original idea was same form for 
> to_char and for to_number --- for to_char() Oracle say:

> SVRMGR> select to_char(SYSDATE, '') from dual;
> TO_CHAR(S
> ---------
>
> 1 row selected.

> I not sure here what is better.

Well, I think there is a good reason for the difference in Oracle's
behavior.  The second case is presumably returning a zero-length string,
not a NULL, and that is a perfectly valid string.  to_number() has no
comparable option, so I think it makes sense for it to raise an error.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Progress report: intraquery memory recovery in executor
Next
From: Philip Warner
Date:
Subject: Re: AW: Re: postgres TODO