Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Conversion functions that would not crash the SQL

BEDEJul 16 2018 — edited Jul 17 2018

Not infrequently we have to take in data from various sources and with formatting errors, so that an insert into ... select to_date(...) , to_number(...) will crash because the to_number or to_date receive strings that cannot be converted. wouldn't it be good to have some conversion functions that would return null in case the conversion fails. Maybe by adding an extra optional parameter, say raise_except, that would be default 'Y' - raise exception, and, when the developer does not want exception to be raise, he would call that function adding the value 'N' for the optional parameter raise_except.

Thus :

select to_date('30-feb-2018','dd-mon-yyyy') from dual will barf, while select to_date('30-feb-2018','dd-mon-yyyy','N') will return a null.

Comments
Post Details
Added on Jul 16 2018
3 comments
688 views