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