Page 1 of 1

Calling SQL functions and not allowing to throw error.

Posted: Mon Mar 19, 2018 10:27 am
by fane89

when calling to_number() or to_timestamp() function and something goes wrong an exception is thrown.
Is there a possiblity to return null instead of throwing an error? Like safe casting via

Code: Select all

I thought maybe to write custom functions and catch those errors, but it cannot be done via CREATE FUNCTION (SQL Functions).Could it be done via native functions in C? Create wrapping functions which call for example to_number() and if errors are throws to return null?

Or maybe another approach?